:root {
  /* -- Design Tokens -- */
  
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --text-primary: #030712; /* Darker black */
  --text-secondary: #111827; /* Much deeper gray */
  --text-tertiary: #6b7280;
  
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;
  
  --brand-primary: #0070f3;
  --brand-accent: #f7a41d;
  
  --link: var(--brand-primary);
  --link-hover: #0051a2;
  
  --code-bg: #f3f4f6;
  --code-text: #111827; /* Darker code text */
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  
  --spacing-unit: 8px;
  --container-width: 900px;
  --header-height: 64px;
  --page-padding: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --text-primary: #e6edf3; /* Lighter white */
    --text-secondary: #c9d1d9; /* Lighter gray */
    --text-tertiary: #8b949e;
    
    --border-subtle: #30363d;
    --border-strong: #484f58;
    
    --brand-primary: #58a6ff;
    --brand-accent: #f7a41d;
    
    --link: var(--brand-primary);
    --link-hover: #79c0ff;
    
    --code-bg: #161b22;
    --code-text: #e6edf3; /* Lighter code text */
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  }
}

/* -- Reset & Base -- */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-wrap: break-word;
}

/* -- Typography -- */

h1, h2, h3, h4, h5, h6 {
  margin-top: 2em;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  overflow-wrap: break-word;
}

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  color: inherit;
  text-decoration: none;
  transition: none;
}

h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover {
  color: inherit;
  text-decoration: none;
}

h1 {
  font-size: 2.25rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
  margin-bottom: 1.5rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
  overflow-wrap: break-word;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

li {
  margin-bottom: 0.5rem;
}

/* -- Article List (Post/Monthly Index) -- */

.article-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}

.article-list li {
  margin-bottom: 0.75rem;
}

.article-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  text-decoration: none !important;
  transition: all 0.2s ease;
  min-width: 0;
}

.article-item:hover {
  border-color: var(--brand-primary);
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

.article-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1.05rem;
  min-width: 0;
}

.article-date {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-left: 1rem;
  white-space: nowrap;
}

.article-item:hover .article-title {
  color: var(--brand-primary);
}

@media screen and (max-width: 600px) {
  .article-item {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .article-date {
    margin-left: 0;
    font-size: 0.8rem;
  }
}

/* -- Monthly Timeline -- */

.monthly-intro {
  margin-bottom: 3rem;
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.monthly-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0;
  margin-top: 2rem;
}

.monthly-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none !important;
  transition: all 0.2s ease;
}

.monthly-item:hover {
  border-bottom-color: var(--brand-primary);
}

.monthly-item:hover .monthly-item-title {
  color: var(--brand-primary);
}

.monthly-item-title {
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 0;
}

.monthly-item-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  margin-left: 2rem;
  white-space: nowrap;
}

.monthly-date-part {
  font-weight: 600;
  color: var(--text-secondary);
}

.monthly-sep {
  opacity: 0.4;
  color: var(--text-tertiary);
  margin: 0 1px;
}

@media screen and (max-width: 600px) {
  .monthly-item {
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 0;
  }
  
  .monthly-item-meta {
    margin-left: 0;
    font-size: 0.85rem;
  }
}

/* -- Learn Landing Page -- */

.learn-chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 3rem 0;
}

.learn-item {
  display: flex;
  align-items: flex-start;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  text-decoration: none !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
}

.learn-item:hover {
  border-color: var(--brand-primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  background: var(--bg-primary);
}

.learn-num {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-tertiary);
  opacity: 0.2;
  margin-right: 1.25rem;
  line-height: 1;
}

.learn-item:hover .learn-num {
  color: var(--brand-primary);
  opacity: 0.8;
}

.learn-info {
  display: flex;
  flex-direction: column;
}

.learn-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.learn-item:hover .learn-title {
  color: var(--brand-primary);
}

.learn-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* -- Components -- */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
}

@media (prefers-color-scheme: dark) {
  .header {
    background: rgba(13, 17, 23, 0.85);
  }
}

.site-title h1 {
  font-size: 1.25rem;
  margin: 0;
  border: none;
  padding: 0;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.site-title {
  text-decoration: none !important;
  color: var(--text-primary) !important;
}

.site-title:hover {
  color: var(--brand-accent) !important;
}

nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: color 0.2s ease;
}

nav a:hover {
  color: var(--brand-primary);
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  z-index: 50;
  transition: background-color 0.2s;
  margin-right: -0.5rem;
}

.mobile-menu-toggle:hover {
  background: var(--bg-secondary);
}

.mobile-menu-line {
  width: 1.25rem;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.3s;
}

.mobile-menu-line:not(:last-child) {
  margin-bottom: 0.25rem;
}

.mobile-menu-toggle.active .mobile-menu-line:nth-child(1) {
  transform: rotate(45deg) translate(0.375rem, 0.375rem);
}

.mobile-menu-toggle.active .mobile-menu-line:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}

.mobile-menu-toggle.active .mobile-menu-line:nth-child(3) {
  transform: rotate(-45deg) translate(0.375rem, -0.375rem);
}

@media screen and (max-width: 600px) {
  .mobile-menu-toggle {
    display: flex;
  }
}

.content-wrapper {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 2rem var(--page-padding);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--page-padding);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.search-container {
  margin-top: 4rem;
  width: 100%;
}


#search .pagefind-ui, 
#search .pagefind-ui *,
#search .pagefind-ui *::before,
#search .pagefind-ui *::after {
  box-sizing: border-box; 
}

#search .pagefind-ui .pagefind-ui__search-input {
  background-color: transparent;
  color: var(--text-primary);
  border: none;
  border-bottom: 2px solid var(--border-subtle);
  padding: 12px 0 12px 40px;
  font-size: 2rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 24px 24px;
  border-radius: 0;
}

@media (prefers-color-scheme: dark) {
  #search .pagefind-ui .pagefind-ui__search-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
  }
}

#search .pagefind-ui .pagefind-ui__search-input:focus {
  border-bottom-color: var(--brand-primary);
}

/* Hide default Pagefind form icon to prevent duplication */
#search .pagefind-ui .pagefind-ui__form::before {
  display: none;
}

#search .pagefind-ui .pagefind-ui__search-clear {
  display: none;
}

#search .pagefind-ui .pagefind-ui__result {
  list-style: none;
  padding: 0;
  margin: 3rem 0;
  border: none;
  border-bottom: 1px dashed var(--border-subtle);
  padding-bottom: 3rem;
}

#search .pagefind-ui .pagefind-ui__result:last-child {
  border-bottom: none;
}

#search .pagefind-ui .pagefind-ui__result-link {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.75rem;
  text-decoration: none;
  display: inline-block;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

#search .pagefind-ui .pagefind-ui__result-link:hover {
  color: var(--brand-primary);
  text-decoration: none;
}

#search .pagefind-ui .pagefind-ui__result-excerpt {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 1.05rem;
  margin-bottom: 0;
}

#search .pagefind-ui .pagefind-ui__result-excerpt mark {
  background-color: transparent;
  color: var(--brand-primary);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

#search .pagefind-ui .pagefind-ui__result-nested {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0 0 0.5rem;
  padding: 0 0 0 1.5rem;
  border-left: 2px solid var(--border-subtle);
}

#search .pagefind-ui .pagefind-ui__result-nested .pagefind-ui__result-link::before {
  content: none;
  display: none;
}

#search .pagefind-ui .pagefind-ui__result-nested + .pagefind-ui__result-nested {
  margin-top: 0;
  padding-top: 1rem;
}

#search .pagefind-ui .pagefind-ui__result-sub {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

#search .pagefind-ui .pagefind-ui__result-sub::before {
  display: none;
}

#search .pagefind-ui .pagefind-ui__result-sub .pagefind-ui__result-link {
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

#search .pagefind-ui .pagefind-ui__result-sub .pagefind-ui__result-link:hover {
  color: var(--brand-primary);
}

#search .pagefind-ui .pagefind-ui__result-sub .pagefind-ui__result-excerpt {
  font-size: 0.95rem;
  color: var(--text-tertiary);
  opacity: 0.9;
}

#search .pagefind-ui .pagefind-ui__message {
  padding: 2rem 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#search .pagefind-ui .pagefind-ui__button {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  padding: 12px;
  width: 100%;
  cursor: pointer;
  margin-top: 2rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#search .pagefind-ui .pagefind-ui__button:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.main-content {
  width: 100%;
  min-width: 0;
}

.main-content > h1:first-child {
  margin-top: 0;
}

.pagefind-ui__results {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
.main-content div > h1:first-child,
.monthly-intro h1:first-child {
  display: none;
}

.toc-sidebar {
  display: none;
}

.toc-sidebar:not(:has(li)),
.toc-fallback:not(:has(li)) {
  display: none !important;
}

.toc-fallback {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.toc-fallback h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

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

.toc-fallback li {
  margin: 0.4rem 0;
}

.toc-fallback a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
}

.toc-fallback a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}

.toc-fallback ul ul {
  padding-left: 1.5rem;
}

@media screen and (min-width: 1024px) {
  .toc-fallback {
    display: none;
  }
  .container {
    max-width: 1100px;
  }

  .content-wrapper {
    flex-direction: row;
    gap: 3rem;
    max-width: 1100px;
  }
  
  .toc-sidebar {
    display: block;
    width: 240px;
    flex-shrink: 0;
    order: 2;
    font-size: 0.85rem;
  }
  
  .toc-sticky {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
    max-height: calc(100vh - var(--header-height) - 4rem);
    overflow-y: auto;
    padding-left: 1rem;
  }
  
  .toc-sticky h3 {
    margin: 0 0 1rem 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    font-weight: 600;
  }

  .toc-sticky ul {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 1px solid var(--border-subtle);
  }

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

  .toc-sticky li {
    margin: 0;
  }

  .toc-sticky a {
    display: block;
    padding: 0.4rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    line-height: 1.4;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    margin-left: -1px; /* Align border with the container border */
  }

  .toc-sticky ul ul a {
    padding-left: 2rem;
    font-size: 0.95em;
  }
  
  .toc-sticky ul ul ul a {
    padding-left: 3rem;
  }

  .toc-sticky a:hover {
    color: var(--brand-primary);
    border-left-color: var(--brand-primary);
    background: var(--bg-secondary);
    text-decoration: none;
  }
  
  .toc-sticky a.active {
    color: var(--brand-primary);
    border-left-color: var(--brand-primary);
    background: var(--bg-secondary);
  }
  
  .toc-sticky::-webkit-scrollbar { width: 4px; }
  .toc-sticky::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
  color: var(--text-secondary);
  border-left: 3px solid var(--brand-primary);
  background: transparent;
  border-radius: 0;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.6;
}

blockquote p {
  margin: 0;
}

/* -- AI Notice -- */

.ai-notice:empty {
  display: none;
}

.ai-notice {
  margin: 1.5rem 0;
  padding: 0.875rem 1.25rem;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  color: #92400e;
  font-size: 0.95rem;
  line-height: 1.6;
}

@media (prefers-color-scheme: dark) {
  .ai-notice {
    background: #1c1a0e;
    border-color: #b45309;
    border-left-color: #f59e0b;
    color: #fcd34d;
  }
}

/* -- Code Blocks -- */

.code-block-container {
  position: relative;
  margin: 1.5rem 0;
  background: var(--code-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 0;
}

pre {
  display: flex;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9em;
  line-height: 1.6;
  color: var(--code-text);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

pre::-webkit-scrollbar {
  height: 6px;
}

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

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

.line-numbers {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.5rem;
  border-right: 1px solid var(--border-subtle);
  background: var(--code-bg);
  color: var(--text-tertiary);
  text-align: right;
  user-select: none;
  position: sticky;
  left: 0;
  z-index: 10;
  min-width: 2.5rem;
  font-size: 0.9rem;
}

.line-numbers span {
  display: block;
  height: 1.6em;
}

pre code {
  flex-grow: 1;
  display: block;
  padding: 1rem 0.75rem;
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: inherit;
  line-height: 1.6;
  border-radius: 0;
}

:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  background: transparent;
  padding: 0;
  color: var(--code-text);
  border: none;
  display: inline;
  white-space: normal;
  word-break: break-all;
}

.copy-code-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: scale(0.95);
}

.code-block-container:hover .copy-code-btn {
  opacity: 1;
  transform: scale(1);
}

.copy-code-btn:hover {
  background: var(--bg-primary);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.copy-code-btn.copied {
  color: #10b981;
  border-color: #10b981;
}

p:has(+ .code-block-container) {
  margin-bottom: 0.75rem;
}

@media screen and (max-width: 600px) {
  .code-block-container {
    margin-left: -24px;
    margin-right: -24px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .copy-code-btn {
    top: 0.75rem;
    right: 0.75rem;
    background: var(--bg-primary);
  }
  
  .line-numbers {
    padding-left: 1rem;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
}

tr:nth-child(even) {
  background-color: rgba(0,0,0,0.01);
}

img, video, iframe, embed, object, canvas, svg {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

figcaption {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 0;
}

footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 24px;
  background: var(--bg-secondary);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

footer > div {
  max-width: var(--container-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
}

@media screen and (min-width: 640px) {
  footer > div {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

footer a:hover {
  color: var(--brand-primary);
}

footer img {
  height: 20px;
  width: auto;
  vertical-align: middle;
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.2s;
  filter: none; 
}

@media (prefers-color-scheme: dark) {
  footer img {
    filter: invert(1);
  }
}

footer img:hover {
  opacity: 1;
  transform: scale(1.1);
}

footer .social-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* -- Legacy/Utility Classes -- */

.center {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 1.5rem 0;
}

.large {
  font-size: 1.5rem;
  line-height: 1.4;
  font-weight: 300;
}

.bold {
  font-weight: 700;
}

#meta {
  color: var(--text-tertiary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
}

#meta p { margin: 0; }

#meta #author::before {
  content: "by ";
  opacity: 0.7;
}

#prev-next {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
}

#prev-next > div {
  flex: 1;
  min-width: 0;
}

#prev-next a {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: none;
  background: transparent;
  text-decoration: none !important;
}

#prev-next span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: color 0.2s ease;
}

#prev-next a:hover span {
  color: var(--brand-primary);
}

#prev-next > :first-child a::before {
  content: "← PREV";
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#prev-next > :last-child a {
  text-align: right;
  align-items: flex-end;
}

#prev-next > :last-child a::before {
  content: "NEXT →";
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#prev-next > :first-child span::before { content: none; }
#prev-next > :last-child span::after { content: none; }

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

@media screen and (max-width: 600px) {
  :root {
    --page-padding: 20px;
  }

  .header {
    padding: 0;
  }
  
  .content-wrapper {
    padding: 0.75rem var(--page-padding) 1.5rem;
  }
  
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  
  nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    width: 100%;
    background: var(--bg-primary);
    flex-direction: column;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
    z-index: 90;
    gap: 0;
  }

  nav.active {
    display: flex;
  }

  nav a {
    width: 100%;
    padding: 1rem 24px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 1rem;
  }

  nav a:last-child {
    border-bottom: none;
  }

  .article-title, .monthly-item-title {
    overflow-wrap: break-word;
    word-break: break-word;
  }
}

hr {
  border: none;
  margin: 4rem 0;
  height: 1px;
}
