/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange: #F7931A;
  --orange-dark: #E8750A;
  --orange-light: #FFF8F0;
  --orange-mid: #C06A10;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --text-light: #999999;
  --bg: #FFFFFF;
  --bg-light: #FAFAFA;
  --border: #EEEEEE;
  --link: #E8750A;
  --radius: 10px;
  --max-width: 960px;
  --header-height: 56px;
  --toc-width: 200px;
}

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 24px); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

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

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

/* === Header === */
.header {
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo {
  font-size: 18px;
  font-weight: 700;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.header-logo:hover { text-decoration: none; opacity: 0.9; }

.header-logo span {
  font-weight: 400;
  font-size: 14px;
  opacity: 0.85;
}

/* === Header Search === */
.header-search {
  position: relative;
  max-width: 260px;
  flex: 1;
}

.header-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  background: rgba(255,255,255,0.2);
  color: white;
  outline: none;
}

.header-search input::placeholder { color: rgba(255,255,255,0.7); }
.header-search input:focus { background: rgba(255,255,255,0.3); }

.header-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: none;
  stroke: rgba(255,255,255,0.7);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 320px;
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: none;
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
}

.search-results.active { display: block; }

.search-result-item {
  display: block;
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--orange-light); text-decoration: none; }

.search-result-item .category {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-result-item .title {
  font-weight: 500;
  color: var(--text);
}

.search-result-item mark {
  background: rgba(247, 147, 26, 0.2);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.search-no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
}

/* === Page Layout === */
.page-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 24px 48px;
  display: flex;
  align-items: flex-start;
  gap: 40px;
}

/* === Sidebar TOC === */
.toc {
  width: var(--toc-width);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-height) + 24px);
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto;
}

.toc-group {
  margin-bottom: 20px;
}

.toc-category {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-left: 12px;
}

.toc-list {
  list-style: none;
}

.toc-list li {
  border-left: 2px solid var(--border);
}

.toc-list a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: color 0.2s, border-color 0.2s;
  line-height: 1.4;
}

.toc-list a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc-list li.active {
  border-left-color: var(--orange);
}

.toc-list li.active a {
  color: var(--orange);
  font-weight: 500;
}

/* === Main Content === */
.main-content {
  flex: 1;
  min-width: 0;
}

/* === Article Sections === */
.article-section {
  padding-bottom: 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.article-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.article-section h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-top: 4px;
  color: var(--text);
}

.article-section h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}

.article-section p {
  margin-bottom: 16px;
  color: var(--text);
}

.article-section ul, .article-section ol {
  margin: 0 0 16px 24px;
}

.article-section li { margin-bottom: 6px; }

.article-section blockquote {
  border-left: 3px solid var(--orange);
  padding: 12px 16px;
  margin: 16px 0;
  background: var(--orange-light);
  border-radius: 0 6px 6px 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.article-section pre, .article-section code {
  font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
  font-size: 14px;
}

.article-section code {
  background: var(--orange-light);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--orange-mid);
}

.article-section pre {
  background: #2D2D2D;
  color: #f0f0f0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.article-section pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.article-section table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 15px;
}

.article-section th, .article-section td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.article-section th {
  font-weight: 600;
  background: var(--bg-light);
}

.article-section img {
  margin: 16px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.article-section strong { font-weight: 600; }

/* Warning box */
.warning {
  background: #FFF3E0;
  border-left: 3px solid #FF9800;
  padding: 16px;
  margin: 16px 0;
  border-radius: 0 6px 6px 0;
  font-size: 14px;
}

/* === Breadcrumbs (for sub-pages) === */
.breadcrumbs {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 24px;
  font-size: 13px;
  color: var(--text-light);
}

.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--link); }
.breadcrumbs .sep { margin: 0 6px; color: var(--border); }

/* === Category Page (for impressum etc.) === */
.category-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 48px;
}

.category-page h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* === Footer === */
.footer {
  background: var(--bg-light);
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
}

.footer a { color: var(--text-secondary); }

/* === Mobile Menu Button === */
.mobile-menu-btn {
  display: none;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-menu-btn:hover { background: rgba(255,255,255,0.3); }

/* === Responsive === */
@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }

  .page-wrapper {
    flex-direction: column;
    padding: 16px 16px 32px;
  }

  .toc {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: none;
    background: var(--bg);
    z-index: 90;
    padding: 16px 24px 32px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  }

  .toc.open {
    display: block;
  }

  .toc-group {
    margin-bottom: 16px;
  }

  .toc-list li {
    border-left: 3px solid var(--border);
  }

  .toc-list a {
    padding: 10px 12px;
    font-size: 15px;
  }

  .toc-list li.active {
    border-left-color: var(--orange);
  }

  .toc-list li.active a {
    color: var(--orange);
    font-weight: 500;
  }

  .header-inner { padding: 0 16px; }
  .header-search { max-width: 140px; }
  .search-results { min-width: 280px; right: 0; left: auto; }

  .article-section h2 { font-size: 20px; }
}
