/* Farger tilpasset øvingsprosjektet: 1P blå, 2P grønn */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --chip: #f1f5f9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }

/* ---------- topp ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 12px 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 650; }
.topbar .back { text-decoration: none; font-size: .9rem; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.search { min-width: 220px; flex: 0 1 320px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.fagnav { display: flex; gap: 4px; flex-wrap: wrap; }
.fagnav a { text-decoration: none; padding: 4px 9px; border-radius: 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.fagnav a.active, .fagnav a:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- oppsett ---------- */
.layout { max-width: 1280px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.filters { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 18px; max-height: calc(100vh - 96px); overflow: auto; padding-bottom: 12px; }
.filters h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.katlist { display: flex; flex-direction: column; gap: 2px; }
.katlist button { display: flex; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: transparent; padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.katlist button:hover { background: var(--chip); }
.katlist button.active { background: var(--accent); color: #fff; }
.katlist .n { opacity: .7; font-variant-numeric: tabular-nums; }
.filters select { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 4px; cursor: pointer; font-size: .9rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.primary { border: 0; background: var(--accent); color: #fff; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.ghost { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- liste ---------- */
.resultbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; color: var(--muted); font-size: .92rem; flex-wrap: wrap; }
.group { margin-bottom: 34px; }
.group > h2 { font-size: 1.25rem; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.group > h2 small { font-size: .85rem; color: var(--muted); font-weight: 500; }
.task { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; border: 1px solid var(--line); }
.task-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fbfaf8; }
.task-title { font-weight: 650; }
.task-title small { font-weight: 500; color: var(--muted); }
.task-src { color: var(--muted); font-size: .9rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip { background: var(--chip); border-radius: 999px; padding: 2px 10px; font-size: .78rem; white-space: nowrap; }
.chip.main { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.task-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.task-body img { display: block; max-width: 100%; height: auto; }
.task-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 8px 16px 12px; font-size: .88rem; color: var(--muted); }
.task-foot .spacer { flex: 1; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--radius); }

/* ---------- enkeltvisning ---------- */
.viewer { position: fixed; inset: 0; background: rgba(20, 26, 38, .72); z-index: 20; display: none; overflow: auto; padding: 24px 16px 60px; }
.viewer.open { display: block; }
.viewer-card { max-width: 980px; margin: 0 auto; background: var(--surface); border-radius: 14px; overflow: hidden; }
.viewer-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: -24px; background: var(--surface); z-index: 1; }
.viewer-bar .pos { color: var(--muted); font-size: .9rem; margin-right: auto; }
.viewer .task { box-shadow: none; border: 0; margin: 0; border-radius: 0; }
.viewer .task-body { padding: 20px 24px; }
body.noscroll { overflow: hidden; }

/* ---------- forside ---------- */
.hero { max-width: 1100px; margin: 0 auto; padding: 40px 20px 8px; }
.hero h1 { font-size: 2rem; margin: 0 0 8px; }
.hero p { color: var(--muted); max-width: 70ch; margin: 0 0 6px; }
.fagrid { max-width: 1100px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.fagkort { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-decoration: none; color: inherit; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; transition: transform .12s, border-color .12s; }
.fagkort:hover { transform: translateY(-2px); border-color: var(--accent); }
.fagkort .kode { font-size: 1.9rem; font-weight: 750; color: var(--accent); line-height: 1; }
.fagkort .meta { color: var(--muted); font-size: .9rem; }
.fagkort ul { margin: 0; padding: 0; list-style: none; font-size: .85rem; display: flex; flex-direction: column; gap: 3px; }
.fagkort li { display: flex; justify-content: space-between; gap: 8px; }
.fagkort li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.note { max-width: 1100px; margin: 0 auto; padding: 4px 20px 40px; color: var(--muted); font-size: .88rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .filters { position: static; max-height: none; }
  .katlist { flex-direction: row; flex-wrap: wrap; }
  .search { flex: 1 1 100%; }
}
@media print {
  .topbar, .filters, .resultbar, .task-foot button, .viewer { display: none !important; }
  .layout { display: block; padding: 0; }
  body { background: #fff; }
  .task { break-inside: avoid; box-shadow: none; }
}

body.fag-2P { --accent: #16a34a; --accent-soft: #dcfce7; }
.topbar .back { font-weight: 600; }
