/* ==========================================================================
   Solarized Theme — translated from ref-blog (Tailwind) to plain CSS
   ========================================================================== */

/* --- Self-hosted fonts --- */
@font-face {
  font-family: 'Ubuntu';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ubuntu-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Ubuntu';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ubuntu-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ubuntu-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ubuntu-mono-700.woff2') format('woff2');
}

/* --- Variables --- */
:root {
  /* Solarized palette */
  --color-base03: #002b36;
  --color-base02: #073642;
  --color-base01: #586e75;
  --color-base00: #657b83;
  --color-base0:  #839496;
  --color-base1:  #93a1a1;
  --color-base2:  #eee8d5;
  --color-base3:  #fdf6e3;
  --color-yellow:  #b58900;
  --color-orange:  #cb4b16;
  --color-red:     #dc322f;
  --color-magenta: #d33682;
  --color-violet:  #6c71c4;
  --color-blue:    #268bd2;
  --color-cyan:    #2aa198;
  --color-green:   #859900;

  /* Fonts */
  --font-family-sans: "Ubuntu", ui-sans-serif, system-ui, sans-serif;
  --font-family-mono: "Ubuntu Mono", ui-monospace, monospace;

  /* Semantic colors — light mode */
  --bg-primary:     var(--color-base3);
  --bg-secondary:   var(--color-base2);
  --text-primary:   var(--color-base01);
  --text-secondary: var(--color-base00);
  --text-muted:     var(--color-base1);
  --border-color:   var(--color-base1);

  /* Mermaid — solarized-light (beautiful-mermaid) */
  --mermaid-bg:     var(--color-base3);   /* #fdf6e3 */
  --mermaid-fg:     var(--color-base00);  /* #657b83 */
  --mermaid-line:   var(--color-base1);   /* #93a1a1 */
  --mermaid-accent: var(--color-blue);    /* #268bd2 */
  --mermaid-muted:  var(--color-base1);   /* #93a1a1 */
  --mermaid-pie1: var(--color-blue);
  --mermaid-pie2: var(--color-cyan);
  --mermaid-pie3: var(--color-green);
  --mermaid-pie4: var(--color-yellow);
  --mermaid-pie5: var(--color-orange);
  --mermaid-pie6: var(--color-violet);
  --mermaid-pie7: var(--color-magenta);
  --mermaid-pie8: var(--color-red);
}

/* Dark mode */
.dark-theme {
  --bg-primary:     var(--color-base03);
  --bg-secondary:   var(--color-base02);
  --text-primary:   var(--color-base1);
  --text-secondary: var(--color-base0);
  --text-muted:     var(--color-base01);
  --border-color:   var(--color-base01);

  /* Mermaid — solarized-dark (beautiful-mermaid) */
  --mermaid-bg:     var(--color-base03);  /* #002b36 */
  --mermaid-fg:     var(--color-base0);   /* #839496 */
  --mermaid-line:   var(--color-base01);  /* #586e75 */
  --mermaid-accent: var(--color-blue);    /* #268bd2 */
  --mermaid-muted:  var(--color-base01);  /* #586e75 */
  --mermaid-pie1: var(--color-blue);
  --mermaid-pie2: var(--color-cyan);
  --mermaid-pie3: var(--color-green);
  --mermaid-pie4: var(--color-yellow);
  --mermaid-pie5: var(--color-orange);
  --mermaid-pie6: var(--color-violet);
  --mermaid-pie7: var(--color-magenta);
  --mermaid-pie8: var(--color-red);
}

/* --- Base Reset --- */
*, ::after, ::before {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

/* --- Hide Native Scrollbar (post pages only, JS adds class) --- */
html.custom-scroll {
  scrollbar-width: none;
}
html.custom-scroll::-webkit-scrollbar {
  display: none;
}

/* --- Reading Progress Bar --- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background-color: var(--color-blue);
  z-index: 999;
  transition: width 0.1s linear;
}

/* --- Custom Vertical Scrollbar --- */
.custom-scrollbar {
  position: fixed;
  top: 0;
  right: 0;
  width: 8px;
  height: 100vh;
  z-index: 998;
  cursor: pointer;
}

.custom-scrollbar-track {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: color-mix(in srgb, var(--text-muted) 15%, transparent);
}

.custom-scrollbar-thumb {
  position: absolute;
  width: 100%;
  min-height: 30px;
  background-color: var(--text-primary);
  border-radius: 2px;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.custom-scrollbar:hover .custom-scrollbar-thumb {
  opacity: 0.8;
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

img, video {
  max-width: 100%;
  height: auto;
}

.post-content img {
  width: auto;
  max-width: 100%;
  max-height: 700px;
  border-radius: 4px;
  margin-inline: auto;
}

.img-zoom-wrap {
  position: relative;
  display: block;
  cursor: zoom-in;
  overflow: hidden;
  border-radius: 4px;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

.post-content figure {
  margin: 0;
}

.post-content figcaption p {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
}
/* --- Mermaid Diagram Viewer --- */
pre.mermaid {
  position: relative;
  cursor: zoom-in;
}

.diagram-zoom-icon {
  position: absolute;
  top: 0;
  right: 0;
  width: 2.5rem;
  height: 2.5rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  color: var(--bg-primary);
  line-height: 0;
  overflow: hidden;
}

.diagram-zoom-icon::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 2.5rem 2.5rem 0;
  border-color: transparent var(--text-primary) transparent transparent;
}

.diagram-zoom-icon svg {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 14px;
  height: 14px;
  z-index: 1;
}

pre.mermaid:hover .diagram-zoom-icon,
.img-zoom-wrap:hover .diagram-zoom-icon {
  opacity: 1;
}

.diagram-viewer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
}

.diagram-viewer.open {
  display: flex;
}

.diagram-viewer-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.diagram-viewer-canvas.grabbing {
  cursor: grabbing;
}

.diagram-viewer-svg-wrap.image-mode {
  background: none;
  border-radius: 0;
  padding: 0;
}

.diagram-viewer-svg-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  background: var(--bg-secondary);
  border-radius: 4px;
  padding: 0.75rem;
  display: flex;
  justify-content: center;
}

.diagram-viewer-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1001;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: none;
  border-radius: 4px;
  padding: 0.35rem 1rem;
  font-family: var(--font-family-sans);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1.5;
}

.diagram-viewer-close:hover {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.diagram-viewer-hint {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-family-sans);
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.5);
  pointer-events: none;
}


/* --- Typography --- */
body {
  font-family: var(--font-family-sans);
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  margin-bottom: 1rem;
}

p, ul, ol, dl, blockquote, pre, table, figure {
  margin-bottom: 1rem;
}

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

a:hover {
  text-decoration: underline;
}

b, strong {
  font-weight: bolder;
}

small {
  font-size: 80%;
}

ul, ol {
  margin-left: 2rem;
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

li > ul, li > ol {
  margin-bottom: 0;
}

code, pre {
  font-family: var(--font-family-mono);
}

code {
  padding: 0.125rem 0.25rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1em;
}

.post-content code {
  word-break: break-all;
}

.table-wrap code {
  word-break: normal;
}

pre {
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--bg-secondary);
  background-color: var(--bg-secondary);
}

pre > code {
  padding: 0;
  background-color: transparent;
}

blockquote {
  color: var(--text-primary);
  border-left: 4px solid var(--color-blue);
  font-style: normal;
  font-size: 1rem;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
  background-color: var(--bg-secondary);
  padding: 1rem;
}

blockquote blockquote {
  margin-left: 0.5rem;
  margin-right: 0;
}

blockquote > :last-child {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text-primary) 50%, transparent) color-mix(in srgb, var(--text-muted) 15%, transparent);
  margin-bottom: 1rem;
}

.table-wrap table {
  margin-bottom: 0;
}

.table-wrap::-webkit-scrollbar {
  height: 4px;
}

.table-wrap::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--text-muted) 15%, transparent);
}

.table-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-primary) 50%, transparent);
  border-radius: 2px;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-indent: 0;
}

th, td {
  padding: 0.5rem;
  line-height: inherit;
}

th {
  text-align: left;
  vertical-align: bottom;
  border-bottom: 2px solid var(--border-color);
}

td {
  vertical-align: top;
  border-bottom: 1px solid var(--border-color);
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 0.75rem 0;
}

::selection {
  background: var(--color-base03);
  color: var(--color-base0);
}

/* --- Layout --- */
.page-content {
  position: relative;
  margin-inline: auto;
  box-sizing: border-box;
  width: 100%;
  max-width: 48rem;
  padding-inline: 1.5rem;
  padding-block: 2rem;
}

/* --- Site Header --- */
.site-header {
  margin-top: -1rem;
  margin-bottom: 0.75rem;
  display: flex;
  max-width: 48rem;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  transition: color 0.3s, background-color 0.3s, border-color 0.3s;
}

.site-header p {
  font-size: 0.875rem;
}

.smallcap {
  margin: 0;
  flex-shrink: 0;
  font-size: 2rem;
  font-weight: 700;
}

.smallcap a {
  background-color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  letter-spacing: 2px;
  color: var(--bg-primary);
  text-decoration: none;
  transition: all 0.3s;
}

.smallcap a:hover {
  background-color: var(--color-blue);
  color: var(--bg-primary);
  text-decoration: none;
}

/* --- Navigation --- */
.site-header nav {
  margin: 0;
  display: flex;
  height: 2rem;
  flex-shrink: 0;
  align-items: center;
  gap: 0.75rem;
  line-height: 2rem;
  white-space: nowrap;
}

.site-header nav a {
  color: var(--text-primary);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--color-blue);
  text-decoration: underline;
}

/* --- Dark Mode Toggle --- */
.toggle-switch {
  position: relative;
  display: inline-flex;
  height: 1.5rem;
  width: 2.5rem;
  align-items: center;
}

.toggle-input {
  height: 0;
  width: 0;
  opacity: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  cursor: pointer;
  border-radius: 4px;
  background-color: var(--text-muted);
  transition: all 0.3s;
}

.toggle-slider:before {
  position: absolute;
  bottom: 2px;
  left: 2px;
  height: 1.25rem;
  width: 1.25rem;
  border-radius: 3px;
  background-color: var(--bg-primary);
  transition: all 0.3s;
  content: "";
}

.toggle-input:checked + .toggle-slider {
  background-color: var(--text-primary);
}

.toggle-input:checked + .toggle-slider:before {
  transform: translateX(calc(2.5rem - 1.25rem - 4px));
}

.toggle-slider:hover {
  background-color: var(--text-primary);
}

.toggle-input:checked + .toggle-slider:hover {
  background-color: var(--text-secondary);
}

/* --- Home / Post List --- */
.home {
  display: block;
}

.post-list {
  list-style-type: none;
  margin-left: 0;
}

.section-link {
  margin-top: 0;
}

.section-link-label {
  color: var(--text-muted);
  opacity: 0.7;
}

.post-list > li {
  margin-bottom: 0.5rem;
  display: flex;
  list-style-type: none;
  align-items: flex-start;
  gap: 1rem;
}

.post-title-container {
  min-width: 0;
  flex: 1;
}

.post-title-link {
  display: block;
  overflow: hidden;
  font-weight: 400;
  word-break: keep-all;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  text-decoration: none;
}

.post-title-link:hover {
  color: var(--color-blue);
  text-decoration: underline;
}

.post-date {
  flex-shrink: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* --- Single Post --- */
article.post {
  display: block;
}

.post-header {
  margin-bottom: 1rem;
}

.post-title {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 2.5rem;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: -1px;
  word-break: keep-all;
}

.post-meta {
  margin-bottom: 0.75rem;
  font-family: var(--font-family-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.post-meta a, .post-meta a:visited {
  color: var(--text-secondary);
}

.post-meta .tags {
  display: inline;
}

.post-meta .tags a, .post-meta .tags a:visited,
.post-list-tags a, .post-list-tags a:visited {
  background-color: var(--bg-secondary);
  padding: 0.1rem 0.5rem;
}

.post-list-tags {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--font-family-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.post-list-tags a, .post-list-tags a:visited {
  color: var(--text-secondary);
}

/* --- Post Content --- */
.post-content {
  margin-bottom: 2rem;
  font-weight: 400;
}

.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
  margin-top: 2rem;
  font-weight: 400;
  position: relative;
}

.post-content h1 { font-size: 1.4rem; font-weight: 600; }
.post-content h2 { font-size: 1.3rem; font-weight: 600; }
.post-content h3 { font-size: 1.2rem; font-weight: 600; }
.post-content h4 { font-size: 1.1rem; font-weight: 600; }
.post-content h5 { font-size: 1.05rem; font-weight: 600; }
.post-content h6 { font-size: 1rem; font-weight: 600; }

.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
  scroll-margin-top: 2rem;
}

/* Copy link toast */
.copy-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  background: var(--text-primary);
  color: var(--bg-primary);
  font-family: var(--font-family-sans);
  font-size: 0.875rem;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  z-index: 2000;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Heading Anchors --- */
.post-content .anchor {
  position: absolute;
  left: -1.5rem;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.post-content h1:hover .anchor,
.post-content h2:hover .anchor,
.post-content h3:hover .anchor,
.post-content h4:hover .anchor,
.post-content h5:hover .anchor,
.post-content h6:hover .anchor {
  opacity: 1;
}

.post-content .anchor:hover {
  color: var(--color-blue);
  text-decoration: none;
}

.post-content h1:hover, .post-content h2:hover, .post-content h3:hover,
.post-content h4:hover, .post-content h5:hover, .post-content h6:hover {
  cursor: pointer;
  color: var(--color-blue);
  text-decoration: underline;
}

/* --- Side Outline (TOC) --- */
.side-outline {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  max-width: clamp(8rem, 15vw, 14rem);
  max-height: calc(100vh - 6rem);
  text-align: left;
  z-index: 100;
}

.side-outline::before,
.side-outline::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2rem;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}

.side-outline::before {
  top: -2px;
  background: linear-gradient(to bottom, var(--bg-primary), transparent);
}

.side-outline::after {
  bottom: -2px;
  background: linear-gradient(to top, var(--bg-primary), transparent);
}

.side-outline.show-fade-top::before {
  opacity: 1;
}

.side-outline.show-fade-bottom::after {
  opacity: 1;
}

.side-outline-inner {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-left: 0.75rem;
  padding-top: 2rem;
  padding-bottom: 2rem;
  scrollbar-width: none;
}

.side-outline-inner::-webkit-scrollbar {
  display: none;
}

.side-outline-track {
  position: absolute;
  top: 2rem;
  bottom: 2rem;
  left: 0;
  width: 2px;
  background-color: var(--bg-secondary);
}

.side-outline-item {
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
  flex-shrink: 0;
}

.side-outline-item:hover {
  color: var(--text-primary);
}

.side-outline-item.active {
  color: var(--color-blue);
}

.side-outline-item[data-level="2"] {
  font-size: 0.85rem;
}

.side-outline-item[data-level="2"] ~ .side-outline-item[data-level="2"] {
  margin-top: 0.75rem;
}

.side-outline-item[data-level="3"] {
  font-size: 0.65rem;
  padding-left: 0.75rem;
}

/* --- Related Posts --- */
.related-posts {
  margin: 2rem 0;
  border-radius: 3px;
  background-color: var(--bg-secondary);
  padding: 1.5rem;
}

.related-posts h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.related-posts ul {
  margin: 0;
  list-style-type: none;
}

.related-posts li {
  margin-bottom: 0.5rem;
}

.related-posts a {
  color: var(--text-primary);
  text-decoration: none;
}

.related-posts a:hover {
  color: var(--color-blue);
  text-decoration: underline;
}

/* --- Code Highlighting (Chroma / Solarized) --- */
.highlight {
  margin: 1rem 0;
  overflow-x: auto;
  border-radius: 4px;
  background-color: var(--bg-secondary);
  padding: 1rem;
  color: var(--text-secondary);
}

.highlight pre {
  margin: 0;
  border: 0;
  background-color: transparent;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.highlight code {
  background-color: transparent;
  color: inherit;
}

.chroma { background-color: var(--bg-secondary); }
.chroma .err { color: var(--color-red); }
.chroma .lntd { margin: 0; border: 0; padding: 0; vertical-align: top; }
.chroma .lntable { margin: 0; display: block; width: auto; border-spacing: 0; overflow: auto; border: 0; padding: 0; }
.chroma .ln { margin-right: 0.4em; padding: 0 0.4em; color: var(--text-muted); }
.chroma .k  { color: var(--color-green); }
.chroma .kc { color: var(--color-orange); }
.chroma .kd { color: var(--color-blue); }
.chroma .kn { color: var(--color-green); }
.chroma .kp { color: var(--color-green); }
.chroma .kr { color: var(--color-blue); }
.chroma .kt { color: var(--color-red); }
.chroma .n  { color: var(--text-secondary); }
.chroma .na { color: var(--text-secondary); }
.chroma .nb { color: var(--color-yellow); }
.chroma .nc { color: var(--color-blue); }
.chroma .no { color: var(--color-orange); }
.chroma .nd { color: var(--color-blue); }
.chroma .ni { color: var(--color-orange); }
.chroma .ne { color: var(--color-orange); }
.chroma .nf { color: var(--color-blue); }
.chroma .nl { color: var(--text-secondary); }
.chroma .nn { color: var(--text-secondary); }
.chroma .nx { color: var(--text-secondary); }
.chroma .nt { color: var(--color-blue); }
.chroma .nv { color: var(--color-blue); }
.chroma .s  { color: var(--color-cyan); }
.chroma .sa { color: var(--color-cyan); }
.chroma .sb { color: var(--text-muted); }
.chroma .sc { color: var(--color-cyan); }
.chroma .dl { color: var(--color-cyan); }
.chroma .sd { color: var(--text-secondary); }
.chroma .s2 { color: var(--color-cyan); }
.chroma .se { color: var(--color-orange); }
.chroma .sh { color: var(--text-secondary); }
.chroma .si { color: var(--color-cyan); }
.chroma .sx { color: var(--color-cyan); }
.chroma .sr { color: var(--color-red); }
.chroma .s1 { color: var(--color-cyan); }
.chroma .ss { color: var(--color-cyan); }
.chroma .m  { color: var(--color-cyan); }
.chroma .mb { color: var(--color-cyan); }
.chroma .mf { color: var(--color-cyan); }
.chroma .mh { color: var(--color-cyan); }
.chroma .mi { color: var(--color-cyan); }
.chroma .il { color: var(--color-cyan); }
.chroma .mo { color: var(--color-cyan); }
.chroma .o  { color: var(--color-green); }
.chroma .ow { color: var(--color-green); }
.chroma .p  { color: var(--text-secondary); }
.chroma .c  { color: var(--text-muted); }
.chroma .ch { color: var(--text-muted); }
.chroma .cm { color: var(--text-muted); }
.chroma .c1 { color: var(--text-muted); }
.chroma .cs { color: var(--color-green); }
.chroma .cp { color: var(--color-green); }
.chroma .cpf { color: var(--color-green); }
.chroma .gd { color: var(--color-red); }
.chroma .ge { color: var(--text-secondary); font-style: italic; }
.chroma .gr { color: var(--color-red); }
.chroma .gh { color: var(--color-orange); }
.chroma .gi { color: var(--color-green); }
.chroma .go { color: var(--text-secondary); }
.chroma .gp { color: var(--text-secondary); }
.chroma .gs { font-weight: 700; color: var(--text-secondary); }
.chroma .gu { color: var(--color-orange); }
.chroma .gt { color: var(--text-secondary); }

/* --- Tag Pages --- */
.tag-list {
  margin-left: 0;
  list-style-type: none;
}

.tag-list li {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

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

/* --- Copyright Footer --- */
.copyright {
  margin-top: 1rem;
  font-family: var(--font-family-mono);
  font-size: 1rem;
}

.copyright p {
  color: var(--text-muted);
}

.copyright a, .copyright a:visited {
  color: var(--text-secondary);
}

/* --- Site Intro --- */
.site-intro {
  margin-bottom: 1rem;
}

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

/* --- Password Protection --- */
.protected-hidden {
  display: none !important;
}

.password-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40vh;
  padding: 2rem 0;
}

.password-prompt {
  text-align: center;
  max-width: 24rem;
  width: 100%;
}

.password-prompt h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.password-prompt p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

#password-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#password-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-family-sans);
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

#password-input:focus {
  border-color: var(--color-blue);
}

#password-submit {
  padding: 0.5rem 1rem;
  font-family: var(--font-family-sans);
  font-size: 1rem;
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

#password-submit:hover {
  background: var(--color-blue);
}

.password-error {
  color: var(--color-red);
  font-size: 0.875rem;
}

.password-disclaimer {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.8;
}

/* --- Responsive --- */
/* Mermaid responsive containers */
pre.mermaid svg {
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

pre.mermaid {
  overflow-x: auto;
  border-radius: 4px;
}

@media (max-width: 1100px) {
  .side-outline {
    display: none;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 1rem;
  }
  .page-content {
    padding-inline: 1rem;
    padding-block: 1.5rem;
  }
  .site-header {
    margin-top: -1rem;
    gap: 0.5rem;
  }
  .smallcap {
    font-size: 1.75rem;
  }
  .smallcap a {
    padding: 0.2rem 0.4rem;
    letter-spacing: 1px;
  }
  .toggle-switch {
    height: 18px;
    width: 2rem;
  }
  .toggle-slider:before {
    height: 14px;
    width: 14px;
  }
  .toggle-input:checked + .toggle-slider:before {
    transform: translateX(14px);
  }
  .post-title {
    font-size: 2rem;
  }
  .post-content h1 { font-size: 1.2rem; }
  .post-content h2 { font-size: 1.15rem; }
  .post-content h3 { font-size: 1.1rem; }
  .post-content h4 { font-size: 1.05rem; }
  .post-content h5, .post-content h6 { font-size: 1rem; }
}

@media (max-width: 600px) {
  .page-content {
    padding-inline: 1rem;
    padding-block: 1.5rem;
  }
  .post-list > li {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding-right: 0;
  }
  .post-title-container {
    width: 100%;
  }
  .post-title-link {
    display: block;
  }
  .post-date {
    font-size: 0.75rem;
  }
  .smallcap {
    font-size: 1.5rem;
  }
  .smallcap a {
    padding: 0.2rem 0.35rem;
    letter-spacing: 1px;
  }
  .site-header nav {
    gap: 0.5rem;
  }
  .toggle-switch {
    height: 1.25rem;
    width: 2.25rem;
  }
  .toggle-slider:before {
    height: 1rem;
    width: 1rem;
  }
  .toggle-input:checked + .toggle-slider:before {
    transform: translateX(calc(2.25rem - 1rem - 4px));
  }
  .post-title {
    font-size: 1.75rem;
  }
  .post-content .anchor {
    left: -2rem;
  }
  .post-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .post-meta .tags {
    display: block;
    width: 100%;
    margin-top: 0;
  }
  pre {
    margin-inline: -1rem;
    max-width: 100vw;
    border-radius: 0;
    padding-inline: 1rem;
  }
  img {
    height: auto;
    max-width: 100%;
  }
  .post-content {
    word-break: keep-all;
    overflow-wrap: normal;
  }
  blockquote {
    margin-inline: -1rem;
    border-left: 4px solid var(--color-blue);
    background-color: var(--bg-secondary);
    padding-inline: 1rem;
  }
  blockquote blockquote {
    margin-inline: 0;
    margin-left: 4px;
  }
}

@media (max-width: 400px) {
  .page-content {
    padding-inline: 0.75rem;
    padding-block: 1.5rem;
  }
  .smallcap {
    font-size: 1.25rem;
  }
  .smallcap a {
    padding: 0.1rem 0.25rem;
    letter-spacing: 1px;
  }
  .site-header nav {
    gap: 0.25rem;
  }
  .toggle-switch {
    height: 18px;
    width: 2rem;
  }
  .toggle-slider:before {
    height: 14px;
    width: 14px;
  }
  .toggle-input:checked + .toggle-slider:before {
    transform: translateX(14px);
  }
  .site-header {
    margin-top: -1rem;
  }
  blockquote {
    margin-inline: -0.75rem;
  }
  blockquote blockquote {
    margin-inline: 0;
    margin-left: 4px;
  }
  pre {
    margin-inline: -0.75rem;
  }
}

/* --- KaTeX math rendering --- */
.katex {
  color: var(--text-primary);
  font-size: 1.1em;
}
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}
