:root {
  color-scheme: light dark;

  --font-text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --line-width: 700px;

  --bg-primary: #ffffff;
  --bg-secondary: #f6f6f6;
  --text-normal: #2e2e2e;
  --text-muted: #6e6e6e;
  --text-faint: #a3a3a3;
  --border: #e3e3e3;
  --interactive-accent: #4a6cf7;
  --code-bg: #f6f6f6;
  --code-border: #e3e3e3;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #202020;
    --bg-secondary: #262626;
    --text-normal: #dadada;
    --text-muted: #999999;
    --text-faint: #6e6e6e;
    --border: #3a3a3a;
    --interactive-accent: #7c93ff;
    --code-bg: #262626;
    --code-border: #3a3a3a;
  }
}

:root[data-theme="dark"] {
  --bg-primary: #202020;
  --bg-secondary: #262626;
  --text-normal: #dadada;
  --text-muted: #999999;
  --text-faint: #6e6e6e;
  --border: #3a3a3a;
  --interactive-accent: #7c93ff;
  --code-bg: #262626;
  --code-border: #3a3a3a;
}

* { box-sizing: border-box; }

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

.wrapper {
  max-width: var(--line-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

header.site-header,
footer.site-footer {
  max-width: var(--line-width);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

footer.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.85rem;
}

.site-title {
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-normal);
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-left: 1.25rem;
}
.site-nav a:hover { color: var(--text-normal); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  margin-left: 1.25rem;
  cursor: pointer;
  font-family: inherit;
}
.theme-toggle:hover { color: var(--text-normal); border-color: var(--text-muted); }

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
  margin: 2rem 0 0.75rem;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }

p { margin: 0 0 1.1rem; }

a { color: var(--interactive-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.about { margin-bottom: 0.5rem; }
.about p { color: var(--text-muted); }
.social-links { display: flex; gap: 1rem; margin: 1rem 0 0; }
.social-links a { color: var(--text-muted); font-size: 1.35rem; line-height: 1; }
.social-links a:hover { color: var(--text-normal); text-decoration: none; }

.project-list { list-style: none; padding: 0; margin: 0.5rem 0 1.5rem; }
.project-list li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.project-list li:first-child { border-top: 1px solid var(--border); }
.project-list a { color: var(--text-normal); }

.post-list { list-style: none; padding: 0; margin: 1.5rem 0; }
.post-list li {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.post-list a { color: var(--text-normal); font-weight: 500; }
.post-list time { color: var(--text-faint); font-size: 0.85rem; white-space: nowrap; }

.post-meta { color: var(--text-faint); font-size: 0.85rem; margin: -0.5rem 0 1.5rem; }

.table-scroll { overflow-x: auto; margin: 1.5rem 0; }
.table-scroll table { margin: 0; }
table { border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  position: relative;
}
pre code { background: none; border: none; padding: 0; }
pre.mermaid { text-align: center; }

/* Chroma wickelt Codeblöcke in <div class="highlight"> — der Copy-Button wird
   dort eingehängt, braucht also auch dort den Positionierungs-Anker. */
.highlight { position: relative; }

.copy-code-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.9rem;
  height: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border: 1px solid var(--code-border);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  z-index: 1;
}
.copy-code-button:hover { color: var(--text-normal); border-color: var(--text-muted); }
.copy-code-button.copied { color: #2ea043; border-color: #2ea043; }

img { max-width: 100%; border-radius: 6px; }

blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
}

.toc {
  position: fixed;
  top: 7rem;
  left: calc(50% + (var(--line-width) / 2) + 2.5rem);
  width: 200px;
  max-height: calc(100vh - 9rem);
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.5;
}
.toc-title {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  color: var(--text-faint);
  margin: 0 0 0.6rem;
  font-weight: 600;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc ul ul { padding-left: 0.85rem; }
.toc li { margin: 0.35rem 0; }
.toc a { color: var(--text-muted); text-decoration: none; display: block; }
.toc a:hover { color: var(--text-normal); }
.toc a.active { color: var(--text-normal); font-weight: 700; }

/* Ab hier wird's eng: Content (700px, zentriert) + Lücke + TOC (200px)
   passt nicht mehr sicher neben den Viewport-Rand. TOC ausblenden,
   Content bleibt exakt so wie ohne TOC. */
@media (max-width: 1150px) {
  .toc { display: none; }
}

@media (max-width: 600px) {
  header.site-header, footer.site-footer, .wrapper { padding-left: 1.25rem; padding-right: 1.25rem; }
  body { font-size: 16px; }
}
