:root {
  --bg: #FFFFFF;
  --text: #333333;
  --accent: #4A5D6B;
  --border: #D1D1D1;
  --title: #111111;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4rem 0;
  position: relative;
  overflow: visible;
}

hr::before,
hr::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 1px;
  height: 9px;
  background: var(--border);
}

hr::before { left: 0; }
hr::after { right: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Source Serif 4", serif;
  margin: 0;
  padding: 0;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 690px;
  margin: 0 auto;
  padding: 80px 20px;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 8px;
  z-index: 100;
  transition: top 0.2s;
  font-family: "Inter", sans-serif;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* Focus Styles */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Image/Plot Refinement */
article img,
article figure {
  max-width: 100%;
  height: auto;
  margin: 4rem 0;
  display: block;
}

article iframe {
  width: 100%;
  border: none;
  margin: 4rem 0;
  display: block;
}

article figure img {
  margin: 0;
}

article figcaption {
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  margin-top: 10px;
}


/* Header & Navigation - Restored to Mock v2 */
header {
  margin-bottom: 120px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

header h1,
.site-title {
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
  margin: 0;
}

header h1 a,
.site-title a {
  text-decoration: none;
  color: var(--title);
}

nav a {
  margin-left: 25px;
  text-decoration: none;
  color: var(--text);
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.85;
  transition: opacity 0.2s;
}

nav a:hover {
  opacity: 1;
}

.nav-icon svg {
  vertical-align: middle;
  transform: translateY(-2px);
  /* Nudge up to align with text baseline */
}

/* Global Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--title);
}

/* Base Link Style */
a {
  color: var(--accent);
  text-decoration: none;
  transition: all 0.2s ease;
}

/* Article Links */
article a {
  border-bottom: 1px solid rgba(74, 93, 107, 0.2);
}

article a:hover {
  border-bottom-color: var(--accent);
  background-color: rgba(74, 93, 107, 0.08);
}

/* Typography Synchronization */
article,
.post-entry .summary {
  font-size: 1.2rem;
  line-height: 1.6;
  text-align: justify;
  hyphens: auto;
  text-wrap: pretty;
}

/* Landing Page / List */
.post-entry {
  margin-bottom: 80px;
}

.post-date {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 10px;
  display: block;
}

.post-entry h2 {
  font-size: 2.5rem;
  /* Restored closer to mock, slight reduction to fit line */
  margin: 0 0 15px 0;
  line-height: 1.2;
}

.post-entry h2 a {
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
  display: inline-block;
}

.post-entry h2 a:hover {
  color: var(--accent);
  transform: translateX(8px);
}

.post-entry .summary {
  margin: 0;
  color: var(--text);
}

/* Single Article */
.article-header {
  margin-bottom: 0;
}

.article-header h1 {
  font-size: 2.5rem;
  /* Synchronized with landing page title size */
  margin: 0 0 15px 0;
  line-height: 1.1;
  color: var(--title);
  text-wrap: balance;
}

article h2 {
  font-size: 1.8rem;
  margin: 3rem 0 1.5rem 0;
  line-height: 1.2;
  text-wrap: balance;
  position: relative;
}

article h2::before {
  content: "[";
  position: absolute;
  left: -20px;
  color: var(--accent);
  opacity: 0.6;
  font-family: "JetBrains Mono", monospace;
  font-weight: 400;
}

article h3 {
  font-size: 1.4rem;
  margin: 1.5rem 0 1rem 0;
}

/* Lead refinement */
article:first-of-type > p:first-of-type {
  margin-top: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2.5rem;
  margin-bottom: 3rem;
}

article p:first-of-type,
article p:first-of-type strong,
article p:first-of-type b {
  font-weight: 400;
  color: var(--text);
}

article b,
article strong {
  font-weight: 600;
  color: var(--title);
}

article code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9em;
  background: #F4F4F4;
  padding: 2px 4px;
  border-radius: 3px;
}

article pre,
.highlight pre {
  background: #FFFFFF;
  padding: 2rem;
  margin: 3rem 0;
  border: 1px solid var(--border);
  position: relative;
  overflow: visible;
  white-space: pre-wrap;
  word-wrap: break-word;
}

article pre::before,
article pre::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--accent);
}

article pre::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

article pre::after {
  bottom: -1px;
  right: -1px;
  border-left: 0;
  border-top: 0;
}

article pre code,
.highlight pre code {
  font-size: 0.95rem;
  /* Increased from 0.85rem */
  background: transparent;
  padding: 0;
  border-radius: 0;
}

/* Tables */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 1.1rem;
}

article table th {
  text-align: left;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  padding: 10px;
}

article table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

footer {
  margin-top: 100px;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
}

.footer-section {
  padding: 25px 0;
  border-top: 1px solid var(--border);
}

.footer-nav a {
  color: var(--text);
  opacity: 0.7; /* Increased for contrast */
  transition: opacity 0.3s ease;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.footer-nav a:hover {
  opacity: 1;
}

.back-arrow {
  margin-right: 8px;
  font-size: 1.1rem;
}

.footer-legal {
  opacity: 0.85; /* Increased for contrast */
}

.copyright {
  display: flex;
  align-items: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: -0.2px;
}

.cc-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
}

.cc-link:hover {
  text-decoration: underline;
}


/* Legacy RMarkdown Callouts & Details */
article div[style*="background-color"],
article p[style*="background-color"],
article div[style*="border"],
article blockquote {
  padding: 1.5rem !important;
  margin: 2.5rem 0 !important;
  border-radius: 4px;
}

details {
  margin: 2rem 0;
  padding: 1rem;
  background: #F9F9F9;
  border-radius: 4px;
}

summary {
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  outline: none;
  list-style: none;
  /* Hides the marker in most browsers */
}

summary::-webkit-details-marker {
  display: none;
  /* Hides the marker in Chrome/Safari */
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 20px;
  }

  nav a {
    margin: 0 20px 0 0;
  }

  .article-header h1 {
    font-size: 2.2rem;
  }

  .post-entry h2 {
    font-size: 1.8rem;
  }
}

/* Minimalist Scrollbar */
pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

pre::-webkit-scrollbar-track {
  background: transparent;
}

pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

pre::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}