/* Gemeinsames Stylesheet (FiSi-Prüfungstrainer / Netzwerk-Tools) */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1a1d23;
  --muted: #5a6370;
  --border: #dcdfe5;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-weak: #ecebff;
  --ok: #15803d;
  --ok-weak: #e6f5eb;
  --bad: #b42318;
  --bad-weak: #fdecea;
  --warn: #9a6700;
  --warn-weak: #fff4d6;
  --code-bg: #eef0f4;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
body.tools { --accent: #0f766e; --accent-weak: #e1f4f1; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1d2128;
    --text: #e7e9ec;
    --muted: #9aa3ae;
    --border: #2b3038;
    --accent: #8f8aff;
    --accent-text: #0f1115;
    --accent-weak: #23224a;
    --ok: #4ade80;
    --ok-weak: #11301e;
    --bad: #f87171;
    --bad-weak: #3a1715;
    --warn: #fbbf24;
    --warn-weak: #362a0c;
    --code-bg: #20242c;
    --shadow: none;
    color-scheme: dark;
  }
  body.tools { --accent: #2dd4bf; --accent-weak: #0f2f2b; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 5px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* Kopf & Navigation */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.site-header .inner {
  max-width: 980px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text);
  display: inline-grid; place-items: center; font-size: 14px; font-weight: 800;
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-weak); color: var(--accent); font-weight: 600; }

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }
.site-footer { max-width: 980px; margin: 0 auto; padding: 16px 16px 40px; color: var(--muted); font-size: .875rem; }
.site-footer a { color: var(--muted); }

/* Karten & Raster */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid > .card + .card { margin-top: 0; }
a.card { color: inherit; text-decoration: none; display: block; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .icon { font-size: 1.6rem; margin-bottom: 6px; }
.hero { margin-bottom: 20px; }
.hero p { color: var(--muted); max-width: 680px; }

/* Formulare */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
input.mono, .mono input { font-family: var(--mono); }
input:focus, select:focus, button:focus-visible, a:focus-visible, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 220px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 9px 16px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.secondary:hover { background: var(--surface-2); filter: none; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; background: var(--surface); color: var(--muted); font-weight: 500; padding: 7px 12px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-weak); color: var(--accent); font-weight: 600; }

/* Ergebnisse */
.kv { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
td.mono, th.mono { font-family: var(--mono); }
.table-wrap { overflow-x: auto; }

.badge { white-space: nowrap; display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.bad { background: var(--bad-weak); color: var(--bad); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.accent { background: var(--accent-weak); color: var(--accent); }

.notice { border-radius: 10px; padding: 10px 14px; margin: 12px 0; background: var(--surface-2); }
.notice.ok { background: var(--ok-weak); color: var(--ok); }
.notice.bad { background: var(--bad-weak); color: var(--bad); }
.notice.warn { background: var(--warn-weak); color: var(--warn); }

.field-ok input { border-color: var(--ok); background: var(--ok-weak); }
.field-bad input { border-color: var(--bad); background: var(--bad-weak); }
.hint { font-size: .82rem; margin-top: 3px; min-height: 1.1em; }
.field-ok .hint { color: var(--ok); }
.field-bad .hint { color: var(--bad); }

/* Binärdarstellung */
.bin { font-family: var(--mono); font-size: .9rem; white-space: pre; overflow-x: auto; background: var(--code-bg); padding: 10px 12px; border-radius: 8px; line-height: 1.6; margin-bottom: 14px; }
.bin .n { color: var(--accent); font-weight: 700; }
.bin .h { color: var(--muted); }

/* Übungsaufgaben */
.task-prompt { font-size: 1.35rem; font-weight: 600; margin: 6px 0 16px; word-break: break-all; }
.form-grid .wide { grid-column: 1 / -1; }
tr.badge-row td { background: var(--accent-weak); }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 12px; }

/* Fortschritt */
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* Karteikarten */
.flashcard {
  min-height: 220px; display: flex; flex-direction: column; justify-content: center; text-align: center;
  cursor: pointer; user-select: none; padding: 28px 22px; margin-top: 14px;
}
.flashcard .q { font-size: 1.2rem; font-weight: 600; }
.flashcard .a { font-size: 1.05rem; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.flashcard .e { color: var(--muted); font-size: .92rem; margin-top: 10px; }
.flashcard .topic { color: var(--muted); font-size: .8rem; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }
.keys { margin-top: 18px; }
@media (hover: none) { .keys { display: none; } }
#stage > p.small:first-child { margin-top: 16px; }
.kbd { font-family: var(--mono); font-size: .78rem; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); }

/* Quiz */
fieldset.plain { border: 0; padding: 0; margin: 0 0 14px; }
fieldset.plain legend { padding: 0; margin-bottom: 8px; }
.check-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
label.check { font-weight: 500; display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.quiz-card { margin-top: 14px; }
.quiz-q { font-size: 1.15rem; font-weight: 600; }
.options { display: grid; gap: 8px; margin-top: 14px; }
.options button {
  text-align: left; justify-content: flex-start; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); font-weight: 500; padding: 11px 14px;
}
.options button:hover:not(:disabled) { border-color: var(--accent); filter: none; }
.options button.correct { border-color: var(--ok); background: var(--ok-weak); color: var(--ok); opacity: 1; }
.options button.wrong { border-color: var(--bad); background: var(--bad-weak); color: var(--bad); opacity: 1; }
.options button:disabled { cursor: default; opacity: .75; }

.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: 8px; }

.topic-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.topic-row:last-child { border-bottom: 0; }
.topic-row .progress { grid-column: 1 / -1; }

@media (max-width: 560px) {
  h1 { font-size: 1.45rem; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .nav { margin-left: 0; }
}

/* Netzwerk-Tools */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
button.small-btn, .small-btn { padding: 5px 10px; font-size: .85rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
button.chip { font-size: .82rem; font-family: var(--mono); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 500; }
button.chip:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.grade { display: inline-grid; place-items: center; min-width: 58px; height: 58px; border-radius: 12px; font-size: 1.8rem; font-weight: 800; color: #fff; padding: 0 8px; }
.grade.A { background: #15803d; } .grade.B { background: #4d7c0f; } .grade.C { background: #a16207; } .grade.D { background: #c2410c; } .grade.F { background: #b91c1c; }
.big-ip { font-family: var(--mono); font-size: clamp(1.35rem, 5.5vw, 2.2rem); font-weight: 700; word-break: break-all; line-height: 1.2; }
.summary { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.chain { list-style: none; padding: 0; margin: 0; }
.chain li { padding: 7px 0; border-bottom: 1px dashed var(--border); word-break: break-all; font-size: .92rem; }
.chain li:last-child { border-bottom: 0; }
td.val, div.val { font-family: var(--mono); font-size: .86rem; overflow-wrap: anywhere; }
table.dns { table-layout: fixed; }
table.dns th:nth-child(1) { width: 30%; } table.dns th:nth-child(2) { width: 9%; } table.dns th:nth-child(3) { width: 17%; }
@media (max-width: 560px) { table.dns { table-layout: auto; } }
.section-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.section-title h3 { margin: 0; }
#ext-out { margin-top: 12px; }
.chips + .kv { margin-top: 10px; }
