/* Generischer MD-Site Builder – Theme */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --theme-color: #4F46E5;
  --base-bg: #ffffff;
  --base-color: #1e293b;
  --sidebar-bg: #f8fafc;
  --sidebar-link: #334155;
  --sidebar-link-active: #4F46E5;
  --border-color: #e2e8f0;
  --code-bg: #f1f5f9;
  --code-color: #1e293b;
  --blockquote-bg: #f8fafc;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sidebar-width: 280px;
  --content-max-width: 860px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --base-bg: #0f172a;
    --base-color: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-link: #94a3b8;
    --sidebar-link-active: #818cf8;
    --border-color: #334155;
    --code-bg: #1e293b;
    --code-color: #e2e8f0;
    --blockquote-bg: #1e293b;
  }
}

html { font-size: 16px; }
body {
  font-family: var(--font-family);
  line-height: 1.7;
  color: var(--base-color);
  background: var(--base-bg);
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  padding: 1.5rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  z-index: 50;
}

.sidebar-header { margin-bottom: 1.5rem; }

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--theme-color);
  text-decoration: none;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav > ul > li > a {
  display: block;
  padding: 0.35rem 0.5rem;
  color: var(--sidebar-link);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav > ul > li > a:hover {
  background: var(--border-color);
}

.sidebar-nav > ul > li > a.active {
  color: var(--sidebar-link-active);
  font-weight: 600;
  background: rgba(79, 70, 229, 0.08);
}

.sub-nav {
  margin: 0.2rem 0 0.3rem 0;
  padding-left: 0.75rem !important;
  border-left: 2px solid var(--border-color);
}

.sub-nav li a {
  display: block;
  font-size: 0.82rem;
  font-weight: 400;
  padding: 0.2rem 0.5rem;
  color: var(--sidebar-link);
  text-decoration: none;
  opacity: 0.8;
}

.sub-nav li a:hover {
  opacity: 1;
  color: var(--sidebar-link-active);
}

.content {
  margin-left: var(--sidebar-width);
  max-width: var(--content-max-width);
  padding: 2rem 3rem;
  flex: 1;
  min-width: 0;
}

.markdown-section h1 {
  font-size: 2rem;
  font-weight: 700;
  border-bottom: 2px solid var(--theme-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.markdown-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.markdown-section h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.markdown-section h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.markdown-section p { margin-bottom: 1rem; }

.markdown-section ul, .markdown-section ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.markdown-section li { margin-bottom: 0.25rem; }

.markdown-section a { color: var(--theme-color); text-decoration: none; }
.markdown-section a:hover { text-decoration: underline; }

.markdown-section hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2rem 0;
}

.markdown-section strong { font-weight: 600; }
.markdown-section img { max-width: 100%; height: auto; }

.markdown-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.markdown-section th {
  background: var(--sidebar-bg);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
}

.markdown-section td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.markdown-section tr:last-child td { border-bottom: none; }

.markdown-section code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--code-bg);
  color: var(--code-color);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.markdown-section pre {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  line-height: 1.5;
}

.markdown-section pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

.code-lang-label {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--sidebar-link);
  opacity: 0.5;
  text-transform: uppercase;
}

.markdown-section blockquote {
  border-left: 4px solid var(--theme-color);
  background: var(--blockquote-bg);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 8px 8px 0;
}

.markdown-section blockquote p { margin-bottom: 0; }

.task-item { list-style: none; margin-left: -1.5rem; }
.task-item input[type="checkbox"] { margin-right: 0.5rem; }

.pagination {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--border-color);
  margin-top: 3rem;
  padding-top: 1.5rem;
}

.pagination-link {
  color: var(--theme-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}

.pagination-link:hover { text-decoration: underline; }
.pagination-next { margin-left: auto; }

.menu-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  background: var(--base-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1.25rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  color: var(--base-color);
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}

@media screen and (max-width: 768px) {
  .menu-toggle { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.open { display: block; }
  .content {
    margin-left: 0;
    padding: 3.5rem 1.25rem 2rem;
  }
}

@media print {
  .sidebar, .menu-toggle, .overlay, .pagination { display: none; }
  .content { margin-left: 0; max-width: 100%; }
}
