:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --accent: #2563eb;
  --border-color: #e5e7eb;
  --danger: #dc2626;
  --success: #059669;
}

body {
  /* Using a clean academic blog font stack: serif for body, sans-serif for UI/headings where specified */
  font-family: Georgia, 'Times New Roman', Times, serif;
  line-height: 1.8;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* Layout Wrapper */
.layout-wrapper {
  display: flex;
  flex-direction: row;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  gap: 4rem;
  align-items: stretch;
  justify-content: center;
}

/* Sidebar TOC */
.toc-sidebar {
  flex: 0 0 350px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.toc-sticky {
  position: sticky;
  top: 2rem;
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.toc-sticky h3 {
  margin-top: 0;
  font-size: 1.1rem;
  color: #111827;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.toc-sticky ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-sticky li {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.toc-sticky a {
  text-decoration: none;
  color: var(--text-secondary);
  transition: color 0.2s;
  display: block;
}

.toc-sticky a:hover {
  color: var(--accent);
}

/* Main Content Area */
.main-content {
  flex: 1;
  min-width: 0;
  max-width: 850px;
}

header {
  text-align: center;
  margin-bottom: 3rem;
}

h1, h2, h3, h4, h5, h6 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #111827;
  line-height: 1.3;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

h3 {
  font-size: 1.15rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
  font-size: 1rem;
}

ul, ol {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* We remove the heavy 'card' styling to make it feel like a flowing academic document */
.card {
  padding: 0.5rem 0;
  margin: 0.5rem 0;
}

.card h2:first-of-type,
.card h3:first-of-type {
  margin-top: 0;
}

.highlight {
  color: var(--accent);
  font-weight: 600;
}

.danger {
  color: var(--danger);
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: #111827;
  border-top: 1px solid var(--border-color);
  border-bottom: 2px solid var(--border-color);
}

tr:last-child td {
  border-bottom: 1px solid var(--border-color);
}

tr:hover td {
  background: var(--bg-secondary);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.image-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.image-card img {
  width: 100%;
  height: auto;
  display: block;
}

.image-label {
  padding: 0.75rem;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.metric-card {
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  text-align: center;
  background: var(--bg-secondary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.metric-label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.metric-card p {
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.4;
  font-family: Georgia, serif;
}

.verdict-box {
  border-left: 4px solid var(--accent);
  background: #f0fdf4;
  padding: 1.5rem;
  margin: 2rem 0;
}

.verdict-box h3 {
  margin-top: 0;
  color: #166534;
}

.verdict-box.fatal {
  border-left-color: var(--danger);
  background: #fef2f2;
}

.verdict-box.fatal h3 {
  color: #991b1b;
}

code {
  font-family: 'Fira Code', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  background: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.85em;
  color: #be185d;
}

.mermaid {
  background: #ffffff;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin: 2rem 0;
  overflow-x: auto;
}

/* Responsive Adaptability */
@media (max-width: 1000px) {
  .layout-wrapper {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }
  .toc-sidebar {
    /* Changed from display: none to block so it shows up on mobile */
    display: block;
    flex: none;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-right: 0;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
  }
  .toc-sticky {
    /* Disable sticky positioning on mobile so it doesn't take up half the screen while scrolling */
    position: static;
    max-height: none;
    top: auto;
  }
  .main-content {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  
  /* Prevent tables from overflowing the screen on mobile */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  opacity: 0;
  transform: translateY(20px);
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  z-index: 1000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.back-to-top:hover {
  background-color: #1e40af; /* darker accent */
  transform: translateY(-2px);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

