:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

  /* Shared/Themed Components */
  --nav-bg: #1e293b;
  --nav-text: #ffffff;
  --nav-hover-bg: rgba(255, 255, 255, 0.1);
  --accent-color: #88fa8c;
  --code-bg: #1e293b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);

    --nav-bg: #0f172a;
    /* Slightly darker nav in dark mode for contrast */
    --nav-hover-bg: rgba(255, 255, 255, 0.05);
    --code-bg: #0a0f1d;
  }

  /* Specific overrides for dark mode to fix visibility issues from legacy CSS */
  .list__excerpt {
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
    color: var(--text-main) !important;
    -webkit-mask-image: linear-gradient(to bottom,
        black 0%,
        black 30%,
        rgba(0, 0, 0, 0.5) 40%,
        rgba(0, 0, 0, 0.1) 75%,
        transparent 90%);
    mask-image: linear-gradient(to bottom,
        black 0%,
        black 30%,
        rgba(0, 0, 0, 0.5) 40%,
        rgba(0, 0, 0, 0.1) 75%,
        transparent 90%);
  }
}


body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.625;
}

/* Container Adjustments */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header & Logo Section */
.header {
  background: var(--card-bg);
  padding: 2.5rem 0 1.5rem;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.logo__link {
  text-decoration: none;
  display: block;
}

.logo__title {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--primary-color) !important;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.logo__tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

/* Wide View Menu Bar (Desktop) */
.header__nav {
  background: var(--nav-bg);
  width: 100%;
  border-bottom: 2px solid var(--primary-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2.5rem;
}

.menu__list {
  display: flex !important;
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}

.menu__item {
  display: block !important;
}

.menu__link {
  display: flex !important;
  align-items: center;
  padding: 1.125rem 1.75rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.menu__text {
  color: var(--nav-text) !important;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.menu__link:hover {
  background: var(--nav-hover-bg);
}

.menu__link:hover .menu__text {
  color: var(--accent-color) !important;
  /* Visual feedback on hover */
}

/* Active item highlight if applicable */
.menu__item--active .menu__text {
  color: var(--primary-color);
}

/* Dedicated Mobile Menu (Hidden on Desktop) */
.mobile-menu {
  display: none;
  /* Only shown via media query */
  background: var(--nav-bg);
  width: 100%;
}

.mobile-menu__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.mobile-menu__link {
  display: block;
  padding: 1.25rem;
  color: var(--nav-text);
  text-decoration: none;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
}

.mobile-menu__link:hover {
  background: var(--nav-hover-bg);
  color: var(--accent-color);
}


/* Article List (Card design) & Article Detail */
.list__item,
.post {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

.post {
  padding: 3rem;
  /* More padding for full articles */
}

.list__item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.list__title,
.post__title {
  margin-top: 0;
  margin-bottom: 1rem;
}

.list__title a,
.post__title {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.2;
}

.list__title a:hover {
  color: var(--primary-color);
}

.meta__text {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.list__excerpt,
.post__content {
  color: var(--text-main);
  font-size: 1.0625rem;
  line-height: 1.75;
}

.post__content h2,
.post__content h3 {
  color: var(--text-main);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
}


/* Buttons */
.btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: white !important;
  padding: 0.625rem 1.25rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 0.2s;
}

.btn:hover {
  background-color: var(--primary-hover);
}

/* Sidebar Widgets */
.widget {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.widget__title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--bg-color);
}

.widget__link {
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.9375rem;
}

.widget__link:hover {
  color: var(--primary-color);
}

/* Pagination */
.pagination__item {
  border-radius: 8px !important;
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  padding: 0.5rem 1rem !important;
}

.pagination__item--current {
  background: var(--primary-color) !important;
  color: white !important;
  border-color: var(--primary-color) !important;
}

/* Responsive */
/* Responsive Mobile Styles */
@media (max-width: 768px) {
  .container {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .header {
    padding: 1.5rem 0 !important;
    text-align: center;
  }

  .logo {
    align-items: center !important;
    padding: 0 1rem !important;
  }

  .header__nav {
    display: none !important;
    /* Hide original complex nav on mobile */
  }

  .mobile-menu {
    display: block !important;
    /* Show simple mobile menu */
    margin-bottom: 1.5rem;
  }

  .menu__btn {
    display: none !important;
  }

  .wrapper {
    flex-direction: column;
    margin: 0 !important;
  }

  .primary {
    width: 100% !important;
    padding: 0 !important;
  }

  .sidebar {
    width: 100% !important;
    margin-top: 1rem;
    padding: 0 !important;
  }

  .main__header {
    background: var(--card-bg);
    padding: 1.5rem 1rem !important;
    border-radius: 0 !important;
    margin-bottom: 0.75rem !important;
    border-left: none !important;
    border-right: none !important;
    text-align: center;
  }

  .list__item,
  .post {
    padding: 1.5rem 1rem !important;
    border-radius: 0 !important;
    margin-bottom: 0.75rem !important;
    border-left: none !important;
    border-right: none !important;
  }

  .list__excerpt {
    max-height: 4.5em;
    overflow: hidden;
    position: relative;
    /* Smooth fade-out at the bottom */
    -webkit-mask-image: linear-gradient(to bottom,
        black 0%,
        black 50%,
        rgba(0, 0, 0, 0.7) 70%,
        rgba(0, 0, 0, 0.3) 85%,
        transparent 100%);
    mask-image: linear-gradient(to bottom,
        black 0%,
        black 50%,
        rgba(0, 0, 0, 0.7) 70%,
        rgba(0, 0, 0, 0.3) 85%,
        transparent 100%);
  }

  .pagination {
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    padding: 1rem !important;
  }
}

/* Image improvements */
img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.thumbnail {
  margin: 0 0 1.5rem 0;
  display: block;
}

.thumbnail__image {
  width: 100%;
  object-fit: cover;
  max-height: 400px;
  border-radius: var(--radius);
}

@media (max-width: 768px) {
  .thumbnail {
    margin-bottom: 1rem;
  }

  .thumbnail__image {
    border-radius: 0;
    max-height: 250px;
  }
}

/* Code block improvements */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: var(--bg-color);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

pre code {
  background: transparent;
  padding: 0;
}

pre {
  background: var(--code-bg) !important;
  /* Always dark for code */
  color: #f8fafc;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border-color);
}

/* Modern TOC Styles */
.post__toc {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 0;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.toc__title {
  font-weight: 800;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-color);
  /* User's custom color */
  padding: 1rem 1.5rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  user-select: none;
  transition: background 0.2s;
}

.toc__title::-webkit-details-marker {
  display: none;
}

.toc__title:hover {
  background: #888888;
  /* User's custom hover color */
}

.toc__toggle-icon::after {
  content: '▼';
  font-size: 0.7rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.5;
}

details[open] .toc__toggle-icon::after {
  transform: rotate(180deg);
}

.toc__menu {
  padding: 0 1.5rem 1.5rem;
}

#TableOfContents ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

#TableOfContents ul ul {
  padding-left: 1.25rem;
  border-left: 1px solid var(--border-color);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

#TableOfContents li {
  margin-bottom: 0.5rem;
}

#TableOfContents a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: all 0.2s;
  display: block;
}

#TableOfContents a:hover {
  color: var(--primary-color);
  padding-left: 0.25rem;
}

/* Desktop behavior: Sidebar widget is visible, article TOC is hidden */
@media (min-width: 1200px) {
  .post__toc-container--mobile {
    display: none;
  }

  .sidebar .post__toc {
    display: block;
    position: sticky;
    top: 1rem;
    z-index: 10;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
  }
}

/* Mobile behavior: Article TOC is visible under title, sidebar widget is hidden */
@media (max-width: 1199px) {
  .post__toc-container--mobile {
    display: block;
    width: 100%;
    margin-bottom: 2rem;
  }

  .sidebar .post__toc {
    display: none;
  }

  /* Shared styling for when it is in mobile view */
  .post__toc {
    position: static !important;
    box-shadow: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
}
