:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #1c1d21;
  --muted: #666a73;
  --border: #e2e2dc;
  --accent: #3a5bd9;
  --accent-soft: #e6ebfb;

  --data: #3a6fd9;
  --mirror: #1f9e8f;
  --parity: #d98a1a;
  --q: #8a56d1;
  --ok: #2f9e55;
  --warn: #d98a1a;
  --bad: #d14343;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --surface: #1c1d22;
    --surface-2: #25262c;
    --text: #ececef;
    --muted: #9a9ca5;
    --border: #2f3038;
    --accent: #7d97f5;
    --accent-soft: #252c47;
    --data: #5b8cf0;
    --mirror: #33bfae;
    --parity: #eba23a;
    --q: #a77ef0;
    --ok: #4cc276;
    --bad: #ef6666;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
code, kbd { font-family: var(--mono); font-size: .9em; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header / footer ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.logo { flex-shrink: 0; white-space: nowrap; font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo-mark {
  font-family: var(--mono); font-size: 13px; background: var(--accent); color: #fff;
  border-radius: 6px; padding: 2px 6px;
}
.subnav { display: flex; gap: 4px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
@media (max-width: 520px) { .subnav a { padding: 6px 6px; font-size: 13px; } }
.subnav a {
  color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.subnav a:hover { background: var(--surface-2); color: var(--text); }

.site-footer { color: var(--muted); font-size: 14px; padding: 48px 0; text-align: center; }

/* ---------- Forside ---------- */
.hero { text-align: center; padding: 64px 0 8px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 12px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero > p { color: var(--muted); max-width: 600px; margin: 0 auto 28px; font-size: 18px; }

.search {
  display: flex; align-items: center; gap: 10px;
  max-width: 600px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 18px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search input {
  flex: 1; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 17px; padding: 14px 0; min-width: 0;
}
.search kbd {
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; color: var(--muted); font-size: 12px;
}
.search-status { color: var(--muted); font-size: 14px; min-height: 1.6em; margin: 12px 0 0; }

.category { margin: 36px 0; scroll-margin-top: 72px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; margin: 4px auto 0; }
.chips a {
  font-size: 14px; color: var(--text); text-decoration: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
}
.chips a:hover { border-color: var(--accent); }
.chips span { color: var(--muted); font-size: 12px; margin-left: 2px; }
.category-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.category-icon {
  font-size: 22px; width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.category-head h2 { margin: 0; font-size: 20px; }
.category-head p { margin: 0; color: var(--muted); font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; color: var(--text); text-decoration: none; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
a.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin: 0; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.card.soon { opacity: .6; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 8px 0 0; }
.tags li { font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 999px; }
.badge {
  align-self: flex-start; margin-top: 8px; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* ---------- Emne-side ---------- */
.topic-hero { padding: 48px 0 8px; }
.breadcrumb { font-size: 14px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.topic-hero h1 { font-size: clamp(32px, 5vw, 44px); margin: 8px 0 8px; }
.topic-hero p { color: var(--muted); font-size: 18px; max-width: 680px; margin: 0; }

.section { padding: 40px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 64px; }
.section:last-of-type { border-bottom: 0; }
.section > h2 { font-size: 28px; margin: 0 0 6px; }
.section .eyebrow { color: var(--accent); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.lead { font-size: 17px; max-width: 720px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 20px 0; }
.cols .panel h3 { margin: 0 0 6px; font-size: 17px; }
.cols .panel p { margin: 0; color: var(--muted); font-size: 15px; }
.icon-big { font-size: 26px; display: block; margin-bottom: 8px; }

.callout {
  border-left: 4px solid var(--bad); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px; margin: 20px 0; max-width: 720px;
}
.callout strong { color: var(--bad); }

.technique { display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; align-items: center; margin: 24px 0; }
.technique > * { min-width: 0; }
pre { overflow-x: auto; max-width: 100%; }
.technique h3 { margin: 0 0 6px; }
.technique p { margin: 0; color: var(--muted); }
@media (max-width: 720px) { .technique { grid-template-columns: 1fr; } }

/* Små statiske diagrammer */
.mini { display: flex; gap: 10px; justify-content: center; }
.mini .disk { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.mini .disk span:last-child { font-size: 12px; color: var(--muted); }
.blk {
  width: 44px; height: 30px; border-radius: 6px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: #fff;
}
.blk.d { background: var(--data); }
.blk.m { background: var(--mirror); }
.blk.p { background: var(--parity); }
.blk.q { background: var(--q); }

/* XOR-demo */
.xor { font-family: var(--mono); display: inline-grid; grid-template-columns: auto repeat(4, 40px) auto; gap: 6px; align-items: center; }
.xor .lbl { font-size: 14px; padding-right: 8px; }
.bit {
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  font: 600 18px var(--mono); color: var(--text); cursor: pointer; transition: background .15s;
}
.bit.on { background: var(--data); color: #fff; border-color: transparent; }
.bit.parity { cursor: default; }
.bit.parity.on { background: var(--parity); }
.bit.lost { background: transparent; border-style: dashed; color: var(--bad); cursor: default; }
.bit.rec { outline: 3px solid var(--ok); outline-offset: 1px; }
.xor .rule { grid-column: 1 / -1; border-top: 2px solid var(--text); margin: 2px 0; }
.xor .act { font-family: var(--font); }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 4px; }

table.compare { width: 100%; border-collapse: collapse; font-size: 15px; }
table.compare th, table.compare td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.compare th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }

/* ---------- Knapper ---------- */
.btn {
  font: inherit; font-size: 15px; font-weight: 500; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.segmented button {
  font: inherit; font-size: 14px; font-weight: 600; border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- RAID-simulator ---------- */
.sim { display: grid; gap: 16px; margin-top: 20px; }
.sim > *, .cols > * { min-width: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-end; }
.control label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.control input[type="text"], .control select {
  font: inherit; font-size: 15px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
.control input[type="text"] { font-family: var(--mono); width: 200px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper output { min-width: 28px; text-align: center; font-weight: 700; }
.stepper .btn { padding: 4px 12px; }

.level-desc { color: var(--muted); margin: 0; }

.array { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; }
.drive {
  flex: 1 0 84px; max-width: 130px; display: flex; flex-direction: column; gap: 5px;
  background: var(--surface-2); border: 2px solid transparent; border-radius: 10px; padding: 8px;
  cursor: pointer; position: relative; transition: border-color .15s, opacity .15s;
  font: inherit; color: inherit; text-align: center;
}
.drive:hover { border-color: var(--border); }
.drive-head { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-bottom: 4px; }
.drive-head .led { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.drive.failed { border-color: var(--bad); }
.drive.failed .led { background: var(--bad); }
.drive.failed .cell { opacity: .25; filter: grayscale(1); }
.drive.failed .cell::after { content: "?"; }
.drive.failed .cell > * { display: none; }
.drive.rebuilding { border-color: var(--warn); }
.drive.rebuilding .led { background: var(--warn); animation: blink .5s infinite; }
.drive .progress { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--warn); border-radius: 0 0 8px 8px; animation: fill 2s linear forwards; }
@keyframes blink { 50% { opacity: .2; } }
@keyframes fill { from { width: 0; } to { width: 100%; } }

.drive .cell {
  height: 42px; border-radius: 6px; color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1.1;
  animation: pop .3s backwards;
}
.drive .cell b { font-family: var(--mono); font-size: 16px; }
.drive .cell small { font-family: var(--mono); font-size: 10px; opacity: .85; }
.drive .cell.data { background: var(--data); }
.drive .cell.mirror { background: var(--mirror); }
.drive .cell.parity { background: var(--parity); }
.drive .cell.q { background: var(--q); }
.drive .cell.empty { background: transparent; border: 1px dashed var(--border); color: var(--muted); }
.drive.failed .cell::after { font: 700 18px var(--mono); color: #fff; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }

.status-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.pill { font-weight: 700; font-size: 14px; padding: 4px 12px; border-radius: 999px; color: #fff; }
.pill.ok { background: var(--ok); }
.pill.warn { background: var(--warn); }
.pill.bad { background: var(--bad); }

.readout { font-family: var(--mono); font-size: 22px; letter-spacing: .08em; word-break: break-all; }
.readout .r { color: var(--warn); text-decoration: underline; text-underline-offset: 4px; }
.readout .x { color: var(--bad); }
.explain { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.explain code { color: var(--text); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }

.log { list-style: none; margin: 0; padding: 0; font-size: 14px; max-height: 160px; overflow-y: auto; }
.log li { padding: 4px 0; border-bottom: 1px solid var(--border); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-right: 8px; }

/* ---------- Quiz ---------- */
.quiz { max-width: 680px; }
.quiz-progress { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; }
.quiz h3 { font-size: 20px; margin: 0 0 16px; }
.options { display: grid; gap: 8px; }
.option {
  text-align: left; font: inherit; padding: 12px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.option.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.feedback { margin: 16px 0 0; padding: 12px 16px; border-radius: 10px; background: var(--surface-2); }
.quiz-actions { margin-top: 16px; }
.score { font-size: 44px; font-weight: 800; margin: 0; }

/* ---------- Fælles: tags i beskeder ---------- */
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; color: #fff; background: var(--accent); margin-right: 4px; }
.tag.ans { background: var(--ok); }
.tag.ref { background: var(--parity); }
.tag.err { background: var(--bad); }
.tag.q { background: var(--accent); }

/* ---------- Subnetting ---------- */
.ipbits-static { font-size: 14px; display: grid; gap: 6px; overflow-x: auto; }
.ipbits-static .lbl { display: inline-block; min-width: 90px; color: var(--muted); }
.ipbits-static .h { color: var(--mirror); }
.ipbits-static .sum { border-top: 2px solid var(--text); padding-top: 6px; }

.bitgrid { display: grid; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.bitrow { display: grid; grid-template-columns: 84px auto 1fr; align-items: center; gap: 12px; min-width: max-content; }
.bitrow.sum { border-top: 2px solid var(--text); padding-top: 8px; }
.bitrow .lbl { font-size: 14px; font-weight: 600; color: var(--muted); }
.bitrow .dec { font-size: 15px; font-weight: 600; }
.bits { display: flex; gap: 2px; }
.bits .dot { width: 8px; text-align: center; color: var(--muted); font-weight: 700; }
.b {
  width: 20px; height: 26px; border-radius: 4px; display: grid; place-items: center;
  font: 600 13px var(--mono); border: 0; padding: 0; color: var(--text);
}
.b.net { background: color-mix(in srgb, var(--data) 15%, transparent); }
.b.host { background: color-mix(in srgb, var(--mirror) 15%, transparent); }
.b.net.one { background: var(--data); color: #fff; }
.b.host.one { background: var(--mirror); color: #fff; }
button.b { cursor: pointer; }
button.b:hover { outline: 2px solid var(--accent); }

.splitbar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 2px; }
.splitbar i { flex: 1; background: hsl(var(--h) 60% 55%); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; background: hsl(var(--h) 60% 55%); }

/* ---------- DNS ---------- */
.dns-tree { display: grid; gap: 14px; justify-items: center; }
.dns-tree .lvl { display: flex; gap: 10px; }
.dns-tree .node { font-family: var(--mono); font-size: 13px; padding: 4px 12px; border-radius: 999px; color: #fff; }
.dns-tree .root { background: var(--text); color: var(--bg); }
.dns-tree .tld { background: var(--parity); }
.dns-tree .auth { background: var(--q); }
.dns-tree .host { background: var(--data); }
.dns-tree .dim { opacity: .35; }

.dns-svg { width: 100%; height: auto; display: block; }
.dns-svg .link { stroke: var(--border); stroke-width: 2; stroke-dasharray: 4 4; }
.dns-svg .node rect { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; transition: fill .2s, stroke .2s; }
.dns-svg .node.active rect { stroke: var(--accent); stroke-width: 3; fill: var(--accent-soft); }
.dns-svg text { text-anchor: middle; fill: var(--text); font-family: var(--font); }
.dns-svg .title { font-size: 15px; font-weight: 600; }
.dns-svg .sub { font-size: 12px; fill: var(--muted); font-family: var(--mono); }
.dns-svg .packet circle { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }
.dns-svg .packet.ans circle { fill: var(--ok); }
.dns-svg .packet.ref circle { fill: var(--parity); }
.dns-svg .packet.err circle { fill: var(--bad); }
.dns-msg { margin-top: 10px; min-height: 3.2em; }
.log.steps { list-style: decimal; padding-left: 20px; max-height: 280px; }

/* ---------- TCP ---------- */
.seq-mini, .seq { width: 100%; height: auto; display: block; }
.seq { max-width: 760px; margin: 0 auto; }
.seq-wrap { max-height: 820px; overflow-y: auto; margin-top: 10px; }
.seq-mini .life, .seq .life { stroke: var(--border); stroke-width: 2; }
.seq-mini text, .seq text { fill: var(--text); font-family: var(--font); }
.seq-mini .who, .seq .who { text-anchor: middle; font-weight: 700; font-size: 14px; }
.seq-mini .lab, .seq .lab { text-anchor: middle; font-family: var(--mono); font-size: 12px; }
.seq-mini .lab { font-size: 11px; }
.seq .lab.lost { fill: var(--bad); text-decoration: line-through; }
.seq .side { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.seq .side.bad { fill: var(--bad); font-weight: 700; }
.seq .lostx { fill: var(--bad); font-size: 18px; font-weight: 700; text-anchor: middle; }
.arr { stroke-width: 2.5; stroke: var(--data); }
.arr.syn { stroke: var(--q); }
.arr.synack { stroke: var(--q); }
.arr.ack { stroke: var(--ok); }
.arr.data { stroke: var(--data); }
.arr.fin { stroke: var(--parity); }
.arr.lost { stroke: var(--bad); stroke-dasharray: 6 4; }
.arr.new { stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw .6s ease-out forwards; }
.arr.lost.new { animation: none; stroke-dasharray: 6 4; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.tcp-msg { min-height: 3.2em; }
.readout .buf { opacity: .45; }
