:root {
  --bg: #ffffff;
  --text: #0b1220;
  --muted: #55606a;
  --accent: #0b64ff;
  --header-bg: rgba(255, 255, 255, 0.8);
  --border: rgba(0, 0, 0, 0.06);
  --code-bg: #eef;
  --code-border: rgba(0, 0, 0, 0.06);
  --code-text: #0b1220;
  --card-bg: #fbfdff;
  --max-width: 78rem;
}

:root[data-theme='dark'] {
  --bg: #0b1220;
  --text: #e6eef8;
  --muted: #9aa6b2;
  --accent: #7aa2ff;
  --header-bg: rgba(12, 18, 28, 0.6);
  --border: rgba(255, 255, 255, 0.06);
  --code-bg: #071724;
  --code-border: rgba(255, 255, 255, 0.06);
  --code-text: #e6eef8;
  --card-bg: #07101a;
}

/* Modern base */
html,
body {
  height: 100%;
}

html {
  box-sizing: border-box;
  font-size: 16px
}

*,
*::before,
*::after {
  box-sizing: inherit
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

.wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem;
}

/* Header */
/* Header: make sure minima floats/borders don't interfere with our layout */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  backdrop-filter: blur(6px);
  border-bottom: 0 !important;
  /* remove thin line that can cross content */
  border-top: 0 !important;
  padding: 0.6rem 0;
  /* ensure content sits clear of any borders */
}

/* Ensure header title and nav respect theme colors and override minima defaults */
.site-header .site-title,
.site-header .site-title:visited {
  color: var(--text) !important;
  float: none !important;
  /* override minima float which can cause vertical overlap */
  display: inline-block;
  line-height: 1;
  /* keep title vertically centered within header */
  margin: 0;
  padding: 0.05rem 0;
}

.site-header .site-nav .page-link {
  color: var(--muted) !important;
}

/* Make the menu icon visible color-adaptive on mobile */
.site-header .menu-icon>svg {
  fill: var(--muted) !important;
}

.site-header .wrapper {
  display: flex;
  align-items: center;
  gap: 1rem
}

.site-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center
}

.page-link {
  color: var(--muted);
  text-decoration: none;
  margin-right: 0.75rem
}

.theme-toggle {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem
}

.theme-toggle svg {
  width: 18px;
  height: 18px
}

/* Page content */
.page-content {
  padding: 2.25rem 0
}

.page-content .wrapper {
  background: transparent
}

/* Articles/cards */
article {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid rgba(0, 0, 0, 0.04)
}

/* Responsive tweaks */
@media (max-width:720px) {
  .wrapper {
    padding: 0.75rem
  }

  .site-title {
    font-size: 0.98rem
  }
}

/* Small utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0
}

/* Override minima code styles to be theme-aware */
code,
pre {
  background-color: var(--code-bg) !important;
  border: 1px solid var(--code-border) !important;
  color: var(--code-text) !important;
}

code {
  padding: 1px 5px;
  border-radius: 3px
}

pre {
  padding: 8px 12px;
  overflow-x: auto;
  border-radius: 6px;
  max-width: 100%;
}

pre code {
  background-color: transparent !important;
  border: none !important;
  padding: 0;
}

/* Center images and captions inside page content */
.page-content img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.page-content figure {
  margin: 0;
}

.page-content figcaption,
.page-content p>em {
  display: block;
  text-align: center;
  color: var(--muted);
  margin-top: 0.4rem;
  font-style: italic
}

/* Per-post Table of Contents styles */
.post-toc {
  margin-top: 0.65rem;
  margin-bottom: 0.5rem;
  padding: 0.6rem;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border)
}

.post-toc .toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  color: var(--muted)
}

.post-toc .toc-toggle {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem
}

.post-toc .post-toc-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.25rem
}

.post-toc-list li {
  margin: 0.25rem 0
}

.post-toc-list a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem
}

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

.post-toc-sublist {
  list-style: none;
  margin: 0.15rem 0 0 0.6rem;
  padding: 0
}

.toc-level-3 a {
  font-size: 0.9rem
}

.post-toc[hidden] {
  display: none
}

/* Sticky sidebar layout for post pages */

@media (min-width: 980px) {

  /* Left-hand sticky sidebar layout */
  .post-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
    align-items: start
  }

  .post-toc-sidebar {
    grid-column: 1
  }

  .post-content {
    grid-column: 2;
    min-width: 0;
  }

  .post-toc-sidebar {
    position: relative
  }

  /* The JS sets a computed top value based on header height; fallback top used here */
  .post-toc-sidebar .post-toc {
    position: sticky;
    top: var(--toc-top, 72px);
    margin: 0
  }

  /* When the sidebar is present, hide the inline header TOC to avoid duplicate UI */
  .post-header>#post-toc {
    display: none
  }
}

/* Active link style for scrollspy */
.post-toc-list a.active {
  color: var(--accent);
  font-weight: 600
}

/* Small responsive tweak: keep TOC readable */
@media (max-width: 479px) {
  .post-toc .toc-header {
    font-size: 0.95rem
  }

  .post-toc-list a {
    font-size: 0.95rem
  }
}