:root {
  --bg-primary: #1e1e1e;
  --bg-secondary: #2d2d30;
  --bg-accent: #0f3460;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --accent-blue: #0078d4;
  --accent-amd: #ed1c24;
  --border: #404040;

  /* Custom Component Colors */
  --black: #000;
  --border-light: #444;
  --border-medium: #555;
  --shadow-color-light: rgba(0, 0, 0, 0.1);
  --shadow-color-medium: rgba(0, 0, 0, 0.15);
  --btn-primary-bg: #4444ff;
  --code-bg-purple: #510370;
  --code-bg-highlight: rgba(0, 0, 0, 0.3);
  --code-text-highlight: #68d391;
  --table-row-alt-bg: #3a3a3d;
  --cta-gradient-start: #667eea;
  --cta-gradient-end: #764ba2;
}

/* === Mobile-First Basis-Styles === */
body {
  font-family: "Arial", Verdana, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  padding: 10px;
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

a, a:visited {
  color: var(--accent-blue);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  margin-top: 1.2em;
  margin-bottom: 0.5em;
}
h1 { font-size: 1.8em; }
h2 { font-size: 1.6em; }
h3 { font-size: 1.4em; }
h4 { font-size: 1.2em; }

.wikidoc {
  width: 100%;
  margin: 0 auto;
  padding: 15px;
  float: none;
  box-sizing: border-box;
  background: var(--bg-secondary);
  color: var(--text-primary);
  clear: both;
}

pre, code, .wikidoc pre, .wikidoc code {
  background: var(--bg-secondary);
  color: var(--accent-blue);
  border-radius: 5px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

table, th, td {
  width: 100%;
  font-size: 12px;
  border: 1px solid var(--border);
  border-collapse: collapse;
  background: var(--bg-secondary);
  color: var(--text-primary);
  word-break: break-word;
  hyphens: auto;
}
th {
  background: var(--bg-accent);
  color: var(--text-primary);
  padding: 8px 4px;
}
td {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 8px 4px;
}

a[style*="background: #ff4444"] {
  background: var(--accent-amd) !important;
  color: var(--text-primary) !important;
}
a[style*="background: #44ff44"] {
  background: var(--accent-blue) !important;
  color: var(--text-primary) !important;
}
a[style*="background: linear-gradient"] {
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--bg-accent) 100%) !important;
  color: var(--text-primary) !important;
}

/* Touchfreundliche Buttons/Links */
a[style*="padding: 12px"], a[style*="padding: 15px"], a, button, input[type="button"], input[type="submit"] {
  display: block;
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  margin: 8px 0;
  text-align: center;
  font-size: 1.1em;
  padding: 12px 16px;
}

a + a, button + button {
  margin-top: 8px;
}

/* Bilder und Medien responsiv */
img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 10px auto;
}
iframe, embed, object {
  max-width: 100%;
  height: auto;
}

/* Sidebars und Fixed-Elemente auf Mobile ausblenden */
/* Standardmäßig: Sidebars ausblenden (Mobile-First) */
/* Sidebars und Fixed-Nav werden nur auf kleinen Bildschirmen ausgeblendet */
@media (max-width: 768px) {
  .left, .right, .fixed-nav {
    display: none !important;
    position: static !important;
    width: 100% !important;
  }
}

/* FIX: Ensure the main content area (.wikidoc) is always visible,
   overriding the display:none from .left, .right, etc. if they are on the same element. */
.wikidoc {
  display: block !important;
}

/* === Mobile Table Stacking (up to 480px) === */
@media (max-width: 480px) {
  table, thead, tbody, th, td, tr {
    display: block;
  }

  th {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  tr {
    border: 1px solid var(--border);
    margin-bottom: 10px;
  }

  td {
    border: none;
    position: relative;
    padding-left: 50%;
  }

  td:before {
    content: attr(data-label) ": ";
    position: absolute;
    left: 6px;
    width: 45%;
    text-align: left;
    font-weight: bold;
  }
}

/* === Tablet-Styles (ab 601px) === */
@media only screen and (min-width: 601px) {
  body {
    font-size: 15px;
  }

  .wikidoc {
    width: 90%;
    margin: 0 auto;
    padding: 20px;
  }

  table, th, td {
    font-size: 14px;
  }

  /* FIX: Reset table cell width for traditional table layout.
     The mobile-first style sets td width to 100% for stacking,
     which needs to be undone for wider screens. */
  th, td {
    width: auto;
  }
}

/* === Desktop-Styles (ab 769px) === */
/* REFACTOR: Replaced float layout with a modern, robust CSS Grid layout.
   This is the ideal tool for creating multi-column page layouts. */
@media only screen and (min-width: 769px) {
  :root {
    --left-sidebar-width: 120px;
    --right-sidebar-width: 160px;
    --content-gutter: 16px;
  }

  body {
    display: grid;
    /* Define 3 columns: left sidebar, flexible content, right sidebar */
    grid-template-columns: minmax(var(--left-sidebar-width), 1fr) minmax(480px, 1.5fr) minmax(var(--right-sidebar-width), 1fr);
    grid-gap: var(--content-gutter);
  }

  .wikidoc {
    /* The content will live in the center column defined by the grid */
    max-width: 900px; /* Enforce the maximum content width */
    min-width: 480px; /* Ensure minimum readable width */
    justify-self: center; /* Center the content within its grid column on wide screens */
    width: 100%; /* Ensure it fills its column up to the max-width */
    margin: 0; /* Reset margins used for float layout */
  }

  .left {
    display: block !important;
  }

  .right {
    display: block !important;
  }

  .fixed-nav {
    /* position:fixed takes this element out of the grid flow, which is correct. */
    display: block !important;
    position: fixed !important;
    top: 0;
    z-index: 10;
    width: var(--left-sidebar-width);
  }
}

/* === Große Desktops (ab 1100px) === */
@media (min-width: 1100px) {
  :root {
    --left-sidebar-width: 180px;
    --right-sidebar-width: 240px;
    --content-gutter: 20px;
  }
  .right {
    /* On large screens, make the right sidebar 'sticky' */
    position: fixed;
    top: 0px;
    right: 0;
  }

  /* When right sidebar is fixed, it leaves the grid. Redefine the grid to 2 columns
     and add padding to the body to avoid content overlapping the fixed sidebar. */
  body {
    grid-template-columns: var(--left-sidebar-width) 1fr;
    padding-right: calc(var(--right-sidebar-width) + var(--content-gutter));
  }
}

/* === Custom Component & Page-Specific Styles === */

/* Sidebar Spacing */
.left-sidebar-ad-spacing {
  padding-top: 10px;
}
.right-sidebar-ad-container {
  margin-top: 20px;
}

/* Ads */
.ad-in-article-fluid {
  display: block;
  text-align: center;
}
.ad-in-article-spaced {
  display: block;
  text-align: center;
  margin: 20px 0;
}

/* Logo & Screenshots */
.logo {
  max-width: 200px;
  border-radius: 10px;
  margin: 20px auto;
}
.screenshot {
  border: 1px solid var(--border-light); /* Dark theme friendly border */
  border-radius: 8px;
  box-shadow: 0 4px 8px var(--shadow-color-light);
  margin: 20px 0;
}

/* Video */
.video-container {
  text-align: center;
  margin: 30px 0;
}
.video-player {
  max-width: 100%;
  height: auto;
  border: 2px solid var(--border-medium); /* Dark theme friendly border */
  border-radius: 10px;
  box-shadow: 0 6px 12px var(--shadow-color-medium);
  background: var(--black);
}
.caption {
  margin-top: 15px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Download Sections & Buttons */
.download-section {
  text-align: center;
  margin: 20px 0;
}
.btn {
  display: inline-block;
  width: auto;
  min-height: auto;
  text-decoration: none;
  color: var(--text-primary) !important; /* Ensure color overrides 'a' tag styles */
  margin: 5px;
  border-radius: 5px;
}
.btn-primary {
  background: var(--btn-primary-bg);
  padding: 12px 24px;
}
.btn-large {
  padding: 15px 30px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 16px;
  margin: 10px;
}

/* Code Blocks */
.code-block-md5 {
  background: var(--code-bg-purple);
  padding: 10px;
  border-radius: 5px;
}
.code-block-md5-highlight {
  background: var(--code-bg-highlight);
  color: var(--code-text-highlight);
  padding: 15px;
  border-radius: 8px;
  margin-top: 20px;
  text-align: left;
}

/* Feature Comparison Table */
.feature-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}
.feature-table th, .feature-table td {
  padding: 12px;
  border: 1px solid var(--border);
  width: auto;
}
.feature-table td {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.feature-table .row-alt td {
  background: var(--table-row-alt-bg); /* Slightly lighter than bg-secondary */
  color: var(--text-primary);
}

/* Call to Action Box */
.cta-box {
  text-align: center;
  margin: 40px 0;
  background: linear-gradient(135deg, var(--cta-gradient-start) 0%, var(--cta-gradient-end) 100%);
  color: var(--text-primary);
  padding: 30px;
  border-radius: 15px;
}
.cta-box p {
  font-size: 18px;
  margin: 15px 0;
  color: var(--text-primary);
}

/* Donations & Embeds */
.qr-code {
  width: 130px;
  height: 130px;
  vertical-align: middle;
  margin-left: 10px;
  display: inline-block;
}
.embed-container {
  text-align: center;
  margin-top: 40px;
  margin-bottom: 40px;
}
.embed-item {
  margin-bottom: 20px;
}
.embed-iframe {
  max-width: 100%;
  border: none;
}

/* Footer */
.footer-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 40px;
}