/* CSS Variables */

:root {
  /* Base colors */
  --bg-color: #fff;
  --text-color: #333;
  --heading-color: #333;
  --meta-color: #595959;
  --border-color: #eaeaea;
  --border-color-rgb: 234, 234, 234;
  --text-color-rgb: 51, 51, 51;
  --code-bg: #f5f7fa;
  --code-border: #e2e8f0;
  --code-color: #2a3646;
  --blockquote-border: #a00;
  --highlight-bg: #fffde7;

  /* Typography scale */
  --text-small: 0.75rem;
  --text-base: 1rem;
  --text-large: 1.25rem;
  --text-xlarge: 1.5rem;
  --text-2xlarge: 2rem;
  --text-3xlarge: 2.5rem;
  --text-4xlarge: 3rem;
  --text-code: 0.85rem;
  --text-code-block: 0.9rem;

  /* Essential colors only */
  --yellow-50: #fffde7;
  --yellow-100: #fff9c4;
  --yellow-200: #fff59d;
  --yellow-500: #ffeb3b;
  --yellow-500-rgb: 255, 235, 59;
  --yellow-600: #fdd835;
  --yellow-900: #f57f17;

  --blue-light: #e3f2fd;
  --blue-dark: #1565c0;
  --green-light: #e8f5e9;
  --green-dark: #2e7d32;
  --red-light: #ffebee;
  --red-dark: #b71c1c;

  --gray-100: #f5f5f5;
  --gray-700: #616161;
  --gray-900: #212121;

  /* Spacing system */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;
  --space-4xl: 4rem;

  /* Border radius scale */
  --radius-xs: 2px;
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 50%;

  /* Animation durations */
  --duration-fast: 0.2s;
  --duration-normal: 0.3s;

  /* Breakpoints */
  --breakpoint-mobile: 768px;
  --breakpoint-desktop: 1200px;
  --breakpoint-desktop-lg: 1400px;
  --breakpoint-desktop-xl: 1600px;

  /* Fonts */
  --font-family:
    "Inter", -apple-system, blinkmacsystemfont, "Segoe UI", roboto,
    "Helvetica Neue", arial, sans-serif;
  --font-mono:
    "SF Mono", consolas, monaco, "Andale Mono", "Ubuntu Mono", monospace;

  /* Component colors */
  --link-bg: var(--yellow-50);
  --link-color: var(--gray-900);
  --link-hover-bg: var(--yellow-100);
  --link-underline: 1px solid rgba(var(--text-color-rgb), 0.3);

  --header-bg: #f8f5f0;
  --header-accent: var(--yellow-500);
  --nav-link-bg: rgba(var(--yellow-500-rgb), 0.15);
  --nav-link-hover-bg: var(--yellow-200);

  --info-bg: var(--blue-light);
  --info-color: var(--blue-dark);
  --success-bg: var(--green-light);
  --success-color: var(--green-dark);
  --warning-bg: var(--yellow-100);
  --warning-color: var(--yellow-900);
  --danger-bg: var(--red-light);
  --danger-color: var(--red-dark);

  --input-background: var(--bg-color);
  --text-muted: var(--meta-color);
  --text-2xl: var(--text-2xlarge);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --heading-color: #f5f5f5;
    --meta-color: #a0a0a0;
    --border-color: #333;
    --border-color-rgb: 51, 51, 51;
    --text-color-rgb: 224, 224, 224;
    --code-bg: #1a1d21;
    --code-border: #2c313a;
    --code-color: #e2e6ed;
    --blockquote-border: #cc0000;
    --highlight-bg: #333;
    --gray-100: #2d2d2d;

    --link-bg: rgba(255, 235, 59, 0.1);
    --link-color: var(--yellow-100);
    --link-hover-bg: rgba(255, 235, 59, 0.2);
    --link-underline: 1px solid rgba(var(--yellow-500-rgb), 0.5);

    --header-bg: #1e1e1e;
    --header-accent: var(--yellow-600);
    --nav-link-bg: #2d2d2d;
    --nav-link-hover-bg: rgba(var(--yellow-500-rgb), 0.15);

    --info-bg: rgba(33, 150, 243, 0.1);
    --info-color: #90caf9;

    --success-bg: rgba(76, 175, 80, 0.1);
    --success-color: #a5d6a7;

    --warning-bg: rgba(var(--yellow-500-rgb), 0.1);
    --warning-color: #fff59d;

    --danger-bg: rgba(244, 67, 54, 0.1);
    --danger-color: #ef9a9a;

    --input-background: #1e1e1e;
    --text-muted: var(--meta-color);
    --text-2xl: var(--text-2xlarge);
  }
}

/* Base styles */

/* Font loaded via HTML head */

/* Base elements */
html {
  overflow: hidden scroll;
  background-color: var(--bg-color);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-weight: 400;
  color: var(--text-color);
  line-height: 1.6;
  font-size: var(--text-large);
  background-color: var(--bg-color);
  margin: 0;
  padding: 20px;
  width: 100%;
}

html,
button,
input,
select,
textarea {
  color: var(--text-color);
}

/* Selection styles */
::-moz-selection,
::selection {
  background: var(--highlight-bg);
  text-shadow: none;
}

/* Focus indicators */
*:focus-visible {
  outline: 2px solid var(--yellow-600);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Remove outlines when focus-visible is supported */
@supports selector(:focus-visible) {
  *:focus:not(:focus-visible) {
    outline: none;
  }
}

/* Basic elements */
hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 1rem 0;
  padding: 0;
}

img {
  margin: 10px auto;
  max-width: 100%;
  height: auto;
  display: block;
}

a img {
  border: none;
}

figure {
  margin: 0;
  text-align: center;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

textarea {
  resize: vertical;
}

/* Typography */

/* Content headings */
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  line-height: 1.2;
  color: var(--heading-color);
  margin-top: 1.2em;
  margin-bottom: 0.5em;
}

/* Specific heading sizes */
.markdown h1 {
  font-size: var(--text-2xlarge);
  font-weight: 500;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-color);
}

.markdown h2 {
  font-size: calc(var(--text-2xlarge) * 0.9);
  font-weight: 500;
  letter-spacing: -0.25px;
  padding-bottom: 0.2em;
  border-bottom: 1px solid var(--border-color);
  margin-top: 1.2em;
}

.markdown h3 {
  font-size: var(--text-xlarge);
  font-weight: 400;
  letter-spacing: -0.1px;
  margin-top: 0.9em;
}

.markdown h4 {
  font-size: var(--text-large);
  font-weight: 400;
  margin-top: 0.8em;
  margin-bottom: 0.4em;
}

.markdown h5,
.markdown h6 {
  font-size: var(--text-base);
  font-weight: 400;
  margin-top: 0.7em;
  margin-bottom: 0.3em;
}

/* Heading spacing adjustments */
.markdown h1 + p,
.markdown h2 + p,
.markdown h3 + p,
.markdown h4 + p,
.markdown h5 + p,
.markdown h6 + p {
  margin-top: 0.3em;
}

.markdown > h1:first-child {
  margin-top: 0.3em;
}

.markdown > h2:first-child,
.markdown > h3:first-child {
  margin-top: 0.4em;
}

/* Header anchors */
.header-link-icon {
  visibility: hidden;
  color: var(--meta-color);
  opacity: 0.7;
  margin-left: 0.25em;
}

h1:hover .header-link-icon,
h2:hover .header-link-icon,
h3:hover .header-link-icon,
h4:hover .header-link-icon,
h5:hover .header-link-icon,
h6:hover .header-link-icon {
  visibility: visible;
}

/* Show header link icons on mobile devices */
@media (max-width: 767px) {
  .header-link-icon {
    visibility: visible;
    opacity: 0.5;

    /* Ensure minimum 44px touch target for accessibility */
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.1em;
  }
}

.header-link-icon svg {
  vertical-align: middle;
}

/* Paragraphs */
.markdown p {
  margin-bottom: 0.8em;
}

/* Links */
a {
  background-color: var(--link-bg);
  color: var(--link-color);
  padding: 1px 3px;
  border-radius: var(--radius-xs);
  transition: all var(--duration-fast) ease;
  border-bottom: var(--link-underline);
  text-decoration: none;
  word-break: break-word;
}

a:hover {
  background-color: var(--link-hover-bg);
  border-bottom: 1px solid var(--yellow-600);
  padding-bottom: 2px;
  text-decoration: none;
}

a:focus {
  background-color: var(--link-hover-bg);
  border-bottom: 1px solid var(--yellow-600);
}

/* Link exceptions */
.site-title a,
.site-title a:hover {
  border-bottom: none;
  text-decoration: none;
}

/* Lists */
ul {
  padding-left: 15px;
  list-style: disc inside;
}

ul.flat {
  margin: 0;
  padding: 0;
}

ul.flat li {
  display: inline-block;
  list-style: none;
  margin-left: 0;
}

/* Blockquotes */
blockquote {
  margin-left: 1rem;
  font-style: italic;
  font-size: var(--text-large);
  font-family: Georgia, serif;
  border-left: 3px solid var(--blockquote-border);
  padding-left: 20px;
  line-height: 1.5;
  color: var(--text-color);
  opacity: 0.9;
}

blockquote cite {
  font-size: var(--text-small);
  opacity: 0.8;
}

blockquote em {
  font-weight: 600;
}

/* Details/Summary elements */
details > summary {
  list-style: none;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: var(--radius-xs);
  background-color: var(--link-bg);
  color: var(--link-color);
  display: inline-block;
  transition: background-color var(--duration-fast) ease;
}

details > summary:hover {
  background-color: var(--link-hover-bg);
  border-bottom: 1px solid var(--yellow-600);
  padding-bottom: 2px;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: "\25B6\00a0";
  color: var(--link-color);
  font-size: 0.8em;
}

details[open] > summary::before {
  content: "\25BC\00a0";
  font-size: 0.8em;
}

details > summary code {
  background-color: transparent;
  color: inherit;
  font-family: var(--font-mono);
  font-size: inherit;
  padding: 0;
  border-radius: 0;
  vertical-align: baseline;
}

details > summary a {
  background-color: transparent;
  color: inherit;
  padding: 0;
  border-bottom: none;
}

details > summary a:hover {
  background-color: transparent;
  text-decoration: underline;
}

/* Code styling */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: var(--text-code);
  background-color: var(--code-bg);
  color: var(--code-color);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--code-border);
  white-space: nowrap;
}

/* Code blocks */
.highlight {
  margin: 1.5rem 0;
  overflow: auto;
  border-radius: var(--radius-md);
  background-color: var(--code-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--code-border);
  position: relative;
  max-width: 100%;
}

.highlight::before {
  content: "";
  display: block;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--yellow-500), transparent);
  border-radius: 5px 5px 0 0;
  opacity: 0.7;
}

.highlight pre {
  margin: 0;
  padding: 1.25rem;
  background-color: transparent !important;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-code-block);
  line-height: 1.5;
  tab-size: 4;
}

.highlight pre code {
  display: block;
}

.highlight:not([class*="language-"]) pre code > span {
  display: block;
  position: relative;
  line-height: 1.6;
}

a code {
  border-bottom: none;
}

/* Code block scrollbars */
.highlight::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.highlight::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

.highlight::-webkit-scrollbar-track {
  background: transparent;
}

@media (prefers-color-scheme: dark) {
  .highlight::-webkit-scrollbar-thumb {
    background: var(--gray-700);
  }
}

li code {
  word-break: break-word;
  white-space: normal;
}

@media (max-width: 767px) {
  :not(pre) > code {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* Keyboard shortcuts */
kbd {
  display: inline-block;
  padding: 0.2em 0.4em;
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: var(--radius-sm);
  border: 1px solid var(--code-border);
  box-shadow: 0 1px 0 var(--code-border);
  background-color: var(--bg-color);
  color: var(--code-color);
  margin: 0 0.1em;
}

kbd.combo kbd {
  margin: 0 0.1em;
  box-shadow: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--code-border);
}

kbd.combo .combo-plus {
  margin: 0 0.2em;
  color: var(--meta-color);
}

/* Tables */
table th {
  background-color: var(--code-bg);
}

table th,
table td {
  padding: 10px 20px;
  border: 1px solid var(--border-color);
}

@media (max-width: 767px) {
  table {
    font-size: var(--text-base);
    overflow-x: auto;
    display: block;
    white-space: nowrap;
  }
}

/* Components */

/* Layout containers */
.wrapper,
.container {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  width: 100%;
}

/* Only hide horizontal overflow on mobile to prevent scroll issues */
@media (max-width: 1199px) {
  body {
    overflow-x: hidden;
  }

  .wrapper,
  .container {
    overflow-x: hidden;
  }
}

.container {
  margin-top: 30px;
}

/* Site header */
.header {
  margin-bottom: 30px;
  padding: 30px 25px 25px;
  background-color: var(--header-bg);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.05),
    inset 0 -2px 0 var(--border-color);
  width: 100%;
  max-width: 100%;
  left: 0;
  right: 0;
  overflow: visible;
  position: relative;
}

.header h1,
.header h2 {
  margin: 0;
  padding: 0;
  font-weight: inherit;
  border: none;
  background: none;
}

.header h1 {
  font-size: var(--text-2xlarge);
  line-height: 1.3em;
}

.header h2 {
  font-size: var(--text-large);
  margin-top: 5px;
}

.site-title a {
  color: var(--heading-color);
  font-size: var(--text-4xlarge);
  text-decoration: none !important;
  background-color: transparent;
  padding: 0;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.site-title a:hover {
  color: var(--yellow-600);
  border-bottom: none;
}

.header .site-description {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 30px;
}

.header .site-description h2 {
  flex: 1;
}

.header .site-description nav {
  margin: 0;
  padding: 0 10px;
  border: none;
  min-width: 50px;
  margin-left: 0;
}

.header .site-description nav ul svg {
  max-height: 15px;
  margin: 0 4px;
}

.header .site-description nav ul.flat li {
  margin-right: 8px;
}

/* Header navigation */
.header nav {
  margin-top: 15px;
  border-top: 1px solid var(--border-color);
  overflow: visible;
  position: relative;
}

.header nav ul,
.header nav li {
  margin: 0;
}

.header nav ul.flat {
  padding: 0;
  overflow: visible;
  position: relative;
}

.header nav ul.flat li {
  display: inline-block;
  list-style: none;
  margin-left: 0;
  margin-right: 12px;
  margin-top: 12px;
  text-transform: capitalize;
}

.header nav ul.flat li a {
  background-color: var(--nav-link-bg);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  border-bottom: none;
}

.header nav ul.flat li a:hover {
  background-color: var(--nav-link-hover-bg);
  border-bottom: none;
  padding-bottom: 6px;
}

/* Footer */
.footer {
  text-align: center;
  font-size: var(--text-small);
  color: var(--meta-color);
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
  margin-top: 40px;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}

.copyright {
  font-size: var(--text-small);
  color: var(--text-color);
  font-weight: 500;
  padding: 5px 0;
}

.footer a {
  background-color: transparent;
  color: var(--text-color);
  padding: 0;
  opacity: 0.8;
  transition: opacity var(--duration-fast) ease;
  border-bottom: none;
}

.footer a:hover {
  opacity: 1;
  border-bottom: 1px dotted var(--text-color);
  background-color: transparent;
  padding-bottom: 0;
}

.footer-links {
  margin-top: 5px;
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .footer-links {
    margin-top: 0;
  }
}

/* Post styling */
.post .post-header {
  margin-bottom: 2rem;
}

.post .post-header .title {
  margin: 0;
  font-size: var(--text-3xlarge);
  line-height: 1.1;
  font-weight: 600;
  color: var(--heading-color);
}

.post .post-header .meta {
  display: block;
  margin-top: 0.5rem;
  font-size: var(--text-base);
  color: var(--text-color);
  font-weight: 500;
}

.post .draft-label {
  color: var(--warning-color);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  background-color: var(--warning-bg);
}

.post ul li {
  margin-bottom: 10px;
}

.post ul li p {
  display: inline;
}

/* Recent posts */
.recent-posts .posts .post {
  margin-bottom: 30px;
}

.recent-posts .posts .post .meta,
.list .posts .post .meta {
  font-size: var(--text-base);
  color: var(--text-color);
  font-weight: 500;
  margin-bottom: 4px;
}

.recent-posts .posts .post .description {
  margin-top: 8px;
  line-height: 1.5;
}

.recent-posts .posts .post a.read-more {
  display: inline-block;
  margin-top: 8px;
  font-size: var(--text-base);
  background-color: transparent;
  color: var(--link-color);
  padding: 0;
}

.recent-posts .posts .post a.read-more:hover {
  border-bottom: 1px solid var(--yellow-600);
  padding-bottom: 0;
}

/* Section headers */
.section-header {
  font-size: var(--text-small);
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-color);
  margin-bottom: 20px;
  letter-spacing: 1px;
}

/* Pagination */
.pagination {
  margin: 0;
  padding: 0;
  text-align: left;
  display: flex;
  justify-content: space-between;
}

.pagination li {
  list-style: none;
  display: inline-block;
  margin: 0;
  padding: 0;
}

.pagination .page-prev {
  margin-right: 20px;
  padding-right: 20px;
}

.pagination .page-item.page-prev {
  text-align: left;
}

.pagination .page-item.page-next {
  text-align: right;
}

/* Layout & utilities */

/* Utility classes */
.align-center {
  text-align: center;
}

.align-left {
  text-align: left;
}

.align-right {
  text-align: right;
}

.page-title {
  margin: 0;
}

.smaller {
  font-size: var(--text-small);
}

/* Search */
.search-widget {
  position: relative;
  margin-left: 20px;
}

.search-input {
  width: 140px;
  padding: 6px 12px;
  font-size: 16px; /* Prevents zoom on iOS */
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--input-background);
  color: var(--text-color);
  font-family: var(--font-family);
  transition:
    width 0.2s ease,
    border-color 0.2s ease;
  -webkit-appearance: none; /* Remove iOS styling */
}

.search-input:focus {
  outline: none;
  border-color: var(--link-color);
  width: 180px;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  margin-top: 0;
  background: var(--header-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow: hidden auto;
  z-index: 1000;
  min-width: 280px;
  max-width: min(400px, calc(100vw - 40px));
}

.search-dropdown.hidden {
  display: none;
}

.search-result {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-color);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.1s ease;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover,
.search-result.selected {
  background-color: var(--gray-100);
}

@media (prefers-color-scheme: dark) {
  .search-result:hover,
  .search-result.selected {
    background-color: #2d2d2d;
  }

  .search-dropdown {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    background: var(--header-bg);
  }

  .search-result-title mark {
    background-color: rgba(var(--yellow-500-rgb), 0.3);
  }
}

.search-result-title {
  font-weight: 500;
  margin-bottom: 3px;
  font-size: var(--text-base);
  line-height: 1.3;
}

.search-result-title mark {
  background-color: var(--yellow-200);
  color: var(--text-color);
  padding: 0 2px;
  border-radius: 2px;
}

.search-result-meta {
  font-size: var(--text-small);
  color: var(--text-muted);
  font-weight: 400;
}

.search-result-context {
  margin-top: 4px;
  font-size: var(--text-small);
  color: var(--text-muted);
  line-height: 1.4;
}

.search-no-results {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-small);
}

.search-more {
  padding: 10px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-small);
  border-top: 1px solid var(--border-color);
}

/* Responsive images */
img[src$="#responsive"] {
  width: 50%;
  height: auto;
}

/* Responsive */

/* Mobile styles */
@media (max-width: 767px) {
  body {
    padding: 10px;
    font-size: var(--text-large);
    max-width: 100vw;
    overflow-x: hidden;
  }

  .wrapper,
  .container {
    padding: 0 5px;
  }

  .header {
    padding: 20px 15px;
    margin-left: -10px;
    margin-right: -10px;
    border-radius: 0;
  }

  .header .site-description {
    align-items: center;
    gap: 15px;
  }

  .site-title a {
    font-size: var(--text-3xlarge);
  }

  .post-header .title {
    font-size: var(--text-2xlarge);
  }

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

  .markdown h1 {
    font-size: var(--text-xlarge);
    margin-top: 1.5em;
  }

  .header nav:not(.social) ul.flat li {
    margin-right: 10px;
  }

  .header nav:not(.social) ul.flat li a {
    padding: 8px 12px;
  }

  .search-widget {
    margin-left: 10px;
  }

  .search-input {
    width: 110px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 6px 10px;
  }

  .search-input:focus {
    width: 140px;
  }

  .search-dropdown {
    right: 0;
    left: auto;
    min-width: 240px;
    max-width: min(280px, calc(100vw - 30px));
  }
}

/* Table of Contents */
.post-with-sidebar {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

.toc-sticky {
  margin-bottom: 20px;
  border-radius: var(--radius-md);
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--yellow-500);
  font-size: var(--text-base);
  transition: all var(--duration-normal) ease;
  scroll-margin-top: 20px;
  box-shadow: 0 1px 3px rgba(var(--border-color-rgb), 0.1);
}

.toc-sticky details {
  padding: 8px 12px;
}

.toc-sticky details summary {
  cursor: pointer;
  padding: 8px 4px;
  color: var(--text-color);
  font-weight: 600;
  user-select: none;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) ease;
  position: relative;
}

.toc-sticky details summary:hover {
  background-color: var(--link-bg);
  color: var(--link-color);
}

.toc-sticky details summary::before {
  content: "📋";
  margin-right: 8px;
  font-size: 1em;
  transition: none;
}

.toc-sticky details summary::after {
  content: "▶";
  margin-left: auto;
  font-size: 0.8em;
  color: var(--meta-color);
  transition: transform var(--duration-fast) ease;
  transform-origin: center;
}

.toc-sticky details[open] summary::after {
  transform: rotate(90deg);
}

.toc-sticky details[open] summary {
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  background-color: var(--link-bg);
}

.toc-sticky h2 {
  display: none;
}

.toc-sticky details > :not(summary) {
  animation: toc-fade var(--duration-fast) ease-in-out;
}

@keyframes toc-fade {
  0% {
    opacity: 0;
    transform: translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.toc-sticky li {
  margin: 6px 0;
  line-height: 1.4;
}

.toc-sticky ul ul {
  padding-left: 15px;
}

.toc-sticky a {
  background: transparent;
  padding: 0;
  color: var(--text-color);
  opacity: 0.9;
  display: inline-block;
  border-bottom: 1px solid transparent;
}

.toc-sticky a:hover {
  opacity: 1;
  border-bottom: 1px solid var(--yellow-600);
  color: var(--link-color);
}

/* Mobile TOC button */
.toc-mobile-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--code-bg);
  border: 2px solid var(--yellow-500);
  color: var(--text-color);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all var(--duration-normal) ease;
  cursor: pointer;
  z-index: 99;
}

.toc-mobile-button.visible {
  opacity: 0.9;
  visibility: visible;
  transform: translateY(0);
}

.toc-mobile-button:hover {
  opacity: 1;
  transform: translateY(-2px);
}

/* Desktop TOC positioning */
@media (min-width: 1200px) {
  .post-with-sidebar {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    --toc-top-position: 0px;
  }

  .toc-sticky {
    position: sticky;
    top: 20px;
    float: right;
    margin-right: calc(-220px - 30px);
    width: 220px;
    background: transparent;
    padding: 0 0 0 15px;
    border: none;
    border-left: 3px solid var(--yellow-500);
    border-radius: 0;
    box-shadow: none;
    margin-top: 0;
    margin-bottom: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 90;
    opacity: 0.85;
    transition: opacity var(--duration-fast) ease;
  }

  .toc-sticky:hover {
    opacity: 1;
  }

  .toc-sticky details {
    padding: 0;
    display: block;
  }

  .toc-sticky details summary {
    display: none;
  }

  .toc-sticky details[open] {
    border-bottom: none;
    padding-bottom: 0;
  }

  .toc-sticky h2 {
    display: block;
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--meta-color);
    font-weight: 600;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
  }
}

@media (min-width: 1200px) and (max-width: 1399px) {
  .toc-sticky {
    margin-right: calc(-220px - 15px);
  }
}

@media (min-width: 1600px) {
  .toc-sticky {
    margin-right: calc(-220px - 50px);
  }
}

/* Code language badges and special styling */
.highlight[class*="language-"]::after {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--meta-color);
  font-size: 0.7rem;
  font-family: "Inter", sans-serif;
  padding: 0.3rem 0.6rem;
  background: var(--code-bg);
  border-bottom-left-radius: 4px;
  opacity: 0.7;
  text-transform: uppercase;
}

/* Language badges */
.highlight.language-javascript::after,
.highlight.language-js::after {
  content: "JS";
}

.highlight.language-typescript::after,
.highlight.language-ts::after {
  content: "TS";
}

.highlight.language-python::after,
.highlight.language-py::after {
  content: "PY";
}

.highlight.language-bash::after,
.highlight.language-sh::after {
  content: "SH";
}

.highlight.language-html::after {
  content: "HTML";
}

.highlight.language-css::after {
  content: "CSS";
}

.highlight.language-go::after {
  content: "GO";
}

.highlight.language-ruby::after {
  content: "RB";
}

.highlight.language-java::after {
  content: "JAVA";
}

.highlight.language-c::after {
  content: "C";
}

.highlight.language-cpp::after {
  content: "C++";
}

.highlight.language-csharp::after {
  content: "C#";
}

.highlight.language-php::after {
  content: "PHP";
}

.highlight.language-swift::after {
  content: "SWIFT";
}

.highlight.language-rust::after {
  content: "RUST";
}

.highlight.language-kotlin::after {
  content: "KOTLIN";
}

.highlight.language-sql::after {
  content: "SQL";
}

.highlight.language-markdown::after,
.highlight.language-md::after {
  content: "MD";
}

.highlight.language-json::after {
  content: "JSON";
}

.highlight.language-yaml::after,
.highlight.language-yml::after {
  content: "YAML";
}

.highlight.language-toml::after {
  content: "TOML";
}

.highlight.language-xml::after {
  content: "XML";
}

.highlight.language-text::after {
  content: "output";
}

/* Shell command prompts */
.highlight.language-bash pre code::before,
.highlight.language-sh pre code::before {
  content: "$ ";
  color: var(--meta-color);
  opacity: 0.7;
  user-select: none;
}

/* Output styling */
.highlight.language-text pre {
  font-family: var(--font-mono);
  color: var(--meta-color);
  font-size: var(--text-code);
}

/* Print styles */
@media print {
  /* Hide navigation and UI elements */
  .header nav,
  .footer,
  .toc-sticky,
  .toc-mobile-button,
  .search-widget {
    display: none !important;
  }

  /* Basic print setup */
  body {
    font-size: 12pt;
    line-height: 1.6;
    color: #000;
    background: #fff;
    max-width: 100%;
  }

  /* Clean up header */
  .header {
    margin-bottom: 30px;
    background: none;
    box-shadow: none;
  }

  /* Links */
  a {
    color: #000;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
  }

  /* Code blocks */
  .highlight {
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .highlight pre {
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  /* Images */
  img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  /* Prevent awkward page breaks */
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    page-break-after: avoid;
  }
}
