/* ==========================================================================
   Yahya On Cloud — Modern Minimalist Design System (CSS Only)
   Editorial + Contemporary Minimal Product Design
   Layout, Typography, Spacing, and Geometry
   ========================================================================== */

:root {
  /* Color Palette - Light Mode (Warm Natural Surface) */
  --bg: #f8f6f0;
  --bg-subtle: #eeeae1;
  --bg-card: #ffffff;
  --bg-card-hover: #faf8f4;
  --text: #1a1a1a;
  --text-muted: #55524c;
  --text-subtle: #736f67;
  --border: #d5d0c5;
  --border-subtle: #e6e2d8;
  --border-strong: #9e988b;

  /* Classic Editorial Hyperlinks */
  --link: #8b4513;
  --link-hover: #a0522d;
  --link-visited: #8b4513;
  --link-active: #654321;

  --primary: #003366;
  --primary-hover: #002244;
  --accent: #003366;

  --tag-bg: #f0eee6;
  --tag-text: #24221e;
  --tag-border: #d0ccc0;

  --code-bg: #ffffff;
  --code-border: #d5d0c5;
  --code-text: #111111;

  --selection-bg: #d2b48c;
  --selection-text: #000000;
  --focus-ring: #8b4513;

  /* Button Controls - Clean, Solid Surface */
  --btn-bg: #ffffff;
  --btn-bg-hover: #eeeae1;
  --btn-border: #d5d0c5;
  --btn-border-hover: #9e988b;
  --btn-text: #1a1a1a;

  /* Typography Stacks */
  --font-heading: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Typography Scale Tokens — Balanced Responsive Hierarchy */
  --text-2xs: 0.75rem;     /* 12px — tiny badges, tags, micro labels */
  --text-xs: 0.8125rem;    /* 13px — metadata, timestamps, mono indicators */
  --text-detail: 0.875rem; /* 14px — secondary details, list items, card copy */
  --text-sm: 0.9375rem;    /* 15px — compact body, job details, UI elements */
  --text-base: 1rem;       /* 16px — standard body copy, hairline titles */
  --text-md: 1.0625rem;    /* 17px — lead intro, featured callouts */
  --text-lg: 1.25rem;      /* 20px — h3, subheadings */
  --text-xl: 1.5rem;       /* 24px — h2, major section headers */
  --text-2xl: 1.875rem;    /* 30px — h1, page titles */

  /* Spacing Scale Tokens */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */

  /* Layout Scale */
  --max-width: 1200px;
  --sidebar-width: 280px;
  --navbar-height: 64px;
  --content-max-width: 820px;
  --prose-max-width: 720px;

  /* Radius System */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  /* Transition Standard */
  --transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

/* Responsive Typography Scale Overrides for Mobile Viewports */
@media (max-width: 768px) {
  :root {
    --text-2xs: 0.6875rem;   /* ~10.3px */
    --text-xs: 0.75rem;      /* ~11.25px */
    --text-detail: 0.8125rem;/* ~12.2px */
    --text-sm: 0.875rem;     /* ~13.1px */
    --text-base: 0.9375rem;  /* ~14px */
    --text-md: 1rem;         /* ~15px */
    --text-lg: 1.15rem;      /* ~17.25px */
    --text-xl: 1.3rem;       /* ~19.5px */
    --text-2xl: 1.55rem;     /* ~23.25px */
  }
}

@media (max-width: 480px) {
  :root {
    --text-2xs: 0.6875rem;   /* ~10px */
    --text-xs: 0.75rem;      /* ~10.9px */
    --text-detail: 0.8125rem;/* ~11.8px */
    --text-sm: 0.85rem;      /* ~12.3px */
    --text-base: 0.9rem;     /* ~13.1px */
    --text-md: 0.95rem;      /* ~13.8px */
    --text-lg: 1.1rem;       /* ~16px */
    --text-xl: 1.25rem;      /* ~18.1px */
    --text-2xl: 1.45rem;     /* ~21px */
  }
}

[data-theme="dark"] {
  /* Color Palette - Dark Mode */
  --bg: #141414;
  --bg-subtle: #1c1c1c;
  --bg-card: #202020;
  --bg-card-hover: #262626;
  --text: #dcdcdc;
  --text-muted: #999999;
  --text-subtle: #808080;
  --border: #383838;
  --border-subtle: #2b2b2b;
  --border-strong: #555555;

  /* Dark Mode Hyperlinks */
  --link: #d2b48c;
  --link-hover: #deb887;
  --link-visited: #d2b48c;
  --link-active: #c19a6b;

  --primary: #66a3ff;
  --primary-hover: #88b8ff;
  --accent: #58a6ff;

  --tag-bg: #1a1a1a;
  --tag-text: #cccccc;
  --tag-border: #383838;

  --code-bg: #181818;
  --code-border: #383838;
  --code-text: #e0e0e0;

  --selection-bg: #8b6d45;
  --selection-text: #000000;
  --focus-ring: #d2b48c;

  /* Button Controls - Dark Mode */
  --btn-bg: #202020;
  --btn-bg-hover: #2b2b2b;
  --btn-border: #383838;
  --btn-border-hover: #555555;
  --btn-text: #dcdcdc;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --bg-subtle: #1c1c1c;
    --bg-card: #202020;
    --bg-card-hover: #262626;
    --text: #dcdcdc;
    --text-muted: #999999;
    --text-subtle: #808080;
    --border: #383838;
    --border-subtle: #2b2b2b;
    --border-strong: #555555;

    --link: #d2b48c;
    --link-hover: #deb887;
    --link-visited: #d2b48c;
    --link-active: #c19a6b;

    --primary: #66a3ff;
    --primary-hover: #88b8ff;
    --accent: #58a6ff;

    --tag-bg: #1a1a1a;
    --tag-text: #cccccc;
    --tag-border: #383838;

    --code-bg: #181818;
    --code-border: #383838;
    --code-text: #e0e0e0;

    --selection-bg: #8b6d45;
    --selection-text: #000000;
    --focus-ring: #d2b48c;

    --btn-bg: #202020;
    --btn-bg-hover: #2b2b2b;
    --btn-border: #383838;
    --btn-border-hover: #555555;
    --btn-text: #dcdcdc;
  }
}

/* ==========================================================================
   Base Reset & Normalization
   ========================================================================== */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scroll-padding-top: calc(var(--navbar-height) + 2.5rem);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
    overflow-x: clip;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14.5px;
  }
}

/* Custom Aesthetic Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

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

::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 9999px;
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background-color 160ms ease;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--border-strong);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  letter-spacing: normal;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background-color: var(--selection-bg);
  color: var(--selection-text);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ==========================================================================
   Typography Hierarchy & Elements
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-break: break-word;
  scroll-margin-top: calc(var(--navbar-height) + 2.5rem);
}

h1 {
  font-size: clamp(1.4rem, 1.15rem + 1.2vw, var(--text-2xl));
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-bottom: var(--space-3);
}

h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

h4 {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

p {
  margin-bottom: var(--space-4);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.45;
  overflow-wrap: break-word;
}

p:last-child {
  margin-bottom: 0;
}

strong, b {
  font-weight: 600;
  color: var(--text);
}

/* Lists */
ul, ol {
  margin: var(--space-2) 0 var(--space-5) var(--space-6);
  padding: 0;
  font-size: var(--text-base);
  line-height: 1.45;
  color: var(--text);
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

li {
  margin-bottom: var(--space-2);
}

li:last-child {
  margin-bottom: 0;
}

li > ul,
li > ol {
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

/* Hyperlinks */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: var(--transition);
}

a:visited {
  color: var(--link-visited);
}

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

a:active {
  color: var(--link-active);
}

/* Monospace & Code */
code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

:not(pre) > code {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--code-border);
  word-break: break-word;
}

pre {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  max-width: 100%;
  line-height: 1.5;
  margin: var(--space-5) 0;
  white-space: pre;
  color: var(--code-text);
}

pre code {
  background: none;
  padding: 0;
  border: 0;
  color: inherit;
  font-size: var(--text-sm);
  white-space: inherit;
}

blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--border-strong);
  background-color: var(--bg-card);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-muted);
  font-size: var(--text-base);
  line-height: 1.45;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-8) 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
}

table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: var(--space-4) 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  font-size: 0.8125rem;
  line-height: 1.45;
}

table th, table td {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-subtle);
  text-align: left;
  font-size: 0.8125rem;
  vertical-align: top;
}

table th {
  background-color: var(--bg-subtle);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

table tr:nth-child(even) td {
  background-color: var(--bg-subtle);
}

table td code {
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  white-space: nowrap;
}

/* ==========================================================================
   Navigation Bar
   ========================================================================== */

.site-navbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background-color: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--navbar-height);
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  flex-shrink: 0;
  transition: border-color 160ms ease;
}

.navbar-container {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding: 0 var(--space-8);
  height: 100%;
}

@media (max-width: 960px) {
  .navbar-container {
    padding: 0 var(--space-5);
  }
}

@media (max-width: 640px) {
  .navbar-container {
    padding: 0 var(--space-4);
  }
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: var(--space-6);
}

.navbar-brand-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  line-height: 1;
  text-decoration: none;
  color: var(--text);
}

.navbar-brand:hover {
  text-decoration: none;
}

.navbar-brand-logo {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.navbar-brand-separator {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  user-select: none;
}

.navbar-brand-subpage {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Desktop navigation links */
.navbar-nav-desktop {
  display: none;
  align-items: center;
  gap: var(--space-1);
}

@media (min-width: 900px) {
  .navbar-nav-desktop {
    display: flex;
  }
}

.navbar-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  background-color: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: var(--transition);
}

.navbar-link:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.navbar-link.active {
  color: var(--text);
  font-weight: 600;
  background-color: var(--bg-card);
  border-color: var(--border-subtle);
  text-decoration: none;
}

/* Dropdown Menu */
.navbar-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.navbar-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  line-height: inherit;
  text-decoration: none;
  transition: var(--transition);
}

.navbar-dropdown-toggle:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.navbar-dropdown-toggle.active {
  color: var(--text);
  font-weight: 600;
  background-color: var(--bg-card);
  border-color: var(--border-subtle);
  text-decoration: none;
}

.dropdown-chevron {
  transition: transform 160ms ease;
}

.navbar-dropdown.is-open .dropdown-chevron {
  transform: rotate(180deg);
}

.navbar-dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  min-width: 160px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
}

.navbar-dropdown.is-open .navbar-dropdown-menu {
  display: flex;
}

/* Hover (and keyboard focus) opens the dropdown — click still toggles via .is-open */
.navbar-dropdown:hover .navbar-dropdown-menu,
.navbar-dropdown:focus-within .navbar-dropdown-menu {
  display: flex;
}

.navbar-dropdown:hover .dropdown-chevron,
.navbar-dropdown:focus-within .dropdown-chevron {
  transform: rotate(180deg);
}

/* Invisible bridge across the menu gap so hover doesn't flicker */
.navbar-dropdown-menu::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--space-2));
  left: 0;
  right: 0;
  height: var(--space-2);
}

.navbar-dropdown-item {
  padding: 0.45rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.navbar-dropdown-item:visited {
  color: var(--text-muted);
}

.navbar-dropdown-item:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.navbar-dropdown-item.active {
  color: var(--text);
  font-weight: 600;
  background-color: var(--bg-subtle);
}

/* Navbar Theme Button */
.navbar-theme-btn,
.navbar-icon-btn,
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: var(--transition);
}

.navbar-theme-btn:hover,
.navbar-icon-btn:hover,
.theme-toggle-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text);
}

.navbar-theme-btn:active,
.navbar-icon-btn:active,
.theme-toggle-btn:active {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.theme-icon-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Mobile Actions */
.navbar-mobile-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

@media (min-width: 900px) {
  .navbar-mobile-actions {
    display: none;
  }
}

/* Mobile Drawer */
.navbar-mobile-drawer {
  display: none;
  flex-direction: column;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-card);
  max-height: 80vh;
  overflow-y: auto;
  position: absolute;
  top: var(--navbar-height);
  left: 0;
  right: 0;
  z-index: 59;
}

.navbar-mobile-drawer.is-open {
  display: flex;
}

.navbar-mobile-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.navbar-mobile-link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.navbar-mobile-link:visited {
  color: var(--text-muted);
}

.navbar-mobile-link.active,
.navbar-mobile-link:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.mobile-nav-group-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 0.25rem 0.75rem;
}

.mobile-nav-group-title.divider {
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem 0.25rem;
}

/* ==========================================================================
   2-Column Layout (Sidebar Left, Content Right)
   ========================================================================== */

.layout-wrapper {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding: var(--space-8) var(--space-8) var(--space-16) var(--space-8);
  display: flex;
  gap: var(--space-12);
  align-items: flex-start;
  flex: 1 0 auto;
}

@media (max-width: 960px) {
  .layout-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-6) var(--space-5) var(--space-12) var(--space-5);
  }
}

@media (max-width: 640px) {
  .layout-wrapper {
    gap: var(--space-5);
    padding: var(--space-4) var(--space-4) var(--space-10) var(--space-4);
  }
}

/* ==========================================================================
   Sidebar (Left Column — Utilitarian / Minimalist Identity)
   ========================================================================== */

.site-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--navbar-height) + var(--space-4));
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.sidebar-toggle-btn {
  display: none !important;
}

.sidebar-collapsible {
  display: block;
}

.sidebar-collapsible-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sidebar-identity {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-avatar-wrap {
  display: block;
  width: 130px;
  height: 130px;
  margin: 0;
}

.sidebar-avatar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
  object-fit: cover;
  border: 1px solid var(--border);
  transition: border-color 160ms ease;
}

.sidebar-avatar-wrap:hover .sidebar-avatar {
  border-color: var(--link);
}

@media (max-width: 960px) {
  .site-sidebar {
    width: 100%;
    position: -webkit-sticky;
    position: sticky;
    top: calc(var(--navbar-height) + 0.35rem);
    z-index: 40;
    margin-bottom: 0;
    padding: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    max-height: calc(100vh - var(--navbar-height) - 1rem);
    transition: border-color 160ms ease, box-shadow 160ms ease;
  }

  .site-sidebar.is-expanded {
    overflow-y: auto;
  }

  .site-sidebar:hover {
    border-color: var(--border-strong);
  }

  .sidebar-inner {
    gap: 0;
  }

  .sidebar-identity {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-avatar-wrap {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
  }

  .sidebar-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
  }

  .sidebar-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
  }

  .sidebar-name {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text);
  }

  /* Inline logo, yahya and dropdown button only in mobile collapsed header */
  .sidebar-identity .sidebar-role,
  .sidebar-identity .sidebar-location {
    display: none !important;
  }

  .sidebar-mobile-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
  }

  .sidebar-mobile-meta .sidebar-role {
    font-size: var(--text-sm);
    color: var(--text);
    font-weight: 500;
  }

  .sidebar-mobile-meta .sidebar-location {
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }

  .sidebar-toggle-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-sm);
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: var(--transition);
  }

  .sidebar-toggle-chevron {
    transition: transform 220ms ease;
  }

  .site-sidebar.is-expanded .sidebar-toggle-chevron {
    transform: rotate(180deg);
  }

  .site-sidebar.is-expanded .sidebar-toggle-btn {
    color: var(--link);
    border-color: var(--border-strong);
  }

  .sidebar-collapsible {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 240ms cubic-bezier(0.2, 0, 0, 1);
  }

  .site-sidebar.is-expanded .sidebar-collapsible {
    grid-template-rows: 1fr;
  }

  .sidebar-collapsible-inner {
    overflow: hidden;
    opacity: 0;
    transition: opacity 200ms ease 40ms, padding 200ms ease;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .site-sidebar.is-expanded .sidebar-collapsible-inner {
    opacity: 1;
    padding: var(--space-4);
    border-top: 1px solid var(--border-subtle);
  }
}

.sidebar-mobile-meta {
  display: none;
}

.sidebar-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-name {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  text-decoration: none;
  letter-spacing: -0.015em;
  transition: color 160ms ease;
}

.sidebar-name:hover {
  color: var(--link);
  text-decoration: none;
}

.sidebar-role {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.4;
}

.sidebar-location {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  letter-spacing: 0.015em;
  line-height: 1.4;
}

.sidebar-location .location-icon {
  color: var(--link);
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.sidebar-summary {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

/* Sidebar Skills */
.sidebar-skills {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

.sidebar-skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.sidebar-skills-tags .tag {
  font-size: var(--text-2xs);
  padding: 0.15rem 0.4rem;
  line-height: 1.3;
}

/* Sidebar Certifications Trophy Grid */
.sidebar-certifications {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.cert-badges {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.cert-badge-link {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-1);
  transition: var(--transition);
  text-decoration: none;
}

.cert-badge-link:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-card-hover);
}

.cert-badge-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Sidebar Cards (Feeds, Index, Links) */
.sidebar-card {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
}

.sidebar-card-header {
  margin-bottom: var(--space-2);
}

.sidebar-card-title {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}

.sidebar-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Sidebar Footer (Socials & Resume) */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-socials-inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sidebar-social-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.sidebar-social-icon-btn:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
  text-decoration: none;
}

.sidebar-social-resume-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: 32px;
  padding: 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.sidebar-social-resume-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
  text-decoration: none;
}

/* Sidebar Feeds & Index — compact rows so they sit quieter than main content */
.sidebar-feeds-list .hairline-row {
  padding: 0.4rem 0.5rem;
  margin: 0 -0.5rem;
  gap: var(--space-2);
}

.sidebar-feeds-list .hairline-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.sidebar-feeds-list .hairline-line {
  display: none;
}

.sidebar-feeds-list .hairline-meta {
  margin-left: auto;
  font-size: 0.75rem;
}

.sidebar-footer-credits {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-subtle);
  line-height: 1.5;
}

/* ==========================================================================
   Main Content Area (Right Column)
   ========================================================================== */

.main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: var(--content-max-width);
  min-height: calc(100vh - var(--navbar-height) - var(--space-8));
  display: flex;
  flex-direction: column;
}

.content-container {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
}

/* Intro Hero on Homepage */
.intro-hero {
  margin-bottom: var(--space-6);
}

.hero-headline {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.bio-content p {
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.bio-content p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Section Components & Hairline Patterns
   ========================================================================== */

.section {
  margin-bottom: var(--space-6);
  min-width: 0;
}

.section:last-child {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-2);
  gap: var(--space-4);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.3;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0;
}

.section-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--link);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
  text-decoration: none;
  transition: var(--transition);
  padding: 0.3rem 0.6rem;
  margin: -0.3rem -0.6rem;
  border-radius: var(--radius-sm);
}

.section-link:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

/* Back links (article / project / paper headers) — navbar-style hover block */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.45rem 0.8rem;
  margin: 0 -0.8rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--link);
  white-space: nowrap;
  text-decoration: none;
  transition: var(--transition);
}

.back-link:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

/* Better Icon Arrows System — Static, Crisp, No Hover Shifting */
.icon-arrow {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  vertical-align: -2px;
  margin-left: 0.25rem;
}

.icon-arrow-left {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  vertical-align: -2px;
  margin-right: 0.35rem;
}

.icon-arrow-external {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  vertical-align: -1px;
  margin-left: 0.25rem;
}

.icon-arrow-up {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.summary-chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--text-subtle);
  transition: transform 160ms ease, color 160ms ease;
}

details[open].experience-item .summary-chevron {
  transform: rotate(90deg);
  color: var(--link);
}

/* Article chrome shared by post / project / paper layouts */
.article-top {
  margin-bottom: 1.5rem;
}

.article-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-tags {
  margin-top: 0.75rem;
}

.article-cover {
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.article-cover-img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.cover-caption {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  margin-top: 0.35rem;
}

/* Small mono uppercase label (eyebrow / spec headings) */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  text-transform: uppercase;
}

.eyebrow-spaced {
  margin-bottom: 0.35rem;
}

.venue-line {
  margin-bottom: 0.25rem;
}

/* Project header spec rows (Period / Role) */
.spec-meta {
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.spec-key {
  color: var(--text-subtle);
}

.spec-val {
  color: var(--text);
}

.tech-stack {
  margin-top: 1rem;
}

/* Row of action buttons */
.btn-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Abstract callout card (research) */
.abstract-card {
  margin-top: 1rem;
  padding: 0.85rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.abstract-text {
  font-size: var(--text-base);
  color: var(--text);
  margin-bottom: 0;
  line-height: 1.5;
}

/* Mobile drawer identity */
.mobile-drawer-name {
  font-weight: 600;
  color: var(--text);
}

.mobile-drawer-sub {
  font-size: 0.825rem;
  color: var(--text-muted);
}

/* Hairline List Rows */
.certifications-list,
.writing-list,
.research-list,
.elsewhere-list,
.projects-minimal-list {
  display: flex;
  flex-direction: column;
}

.certifications-list a,
.certifications-list .hairline-row,
.certifications-list .hairline-title,
.certifications-list .hairline-row:hover .hairline-title {
  text-decoration: none !important;
}

.hairline-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.38rem 0;
  text-decoration: none;
  min-width: 0;
  max-width: 100%;
  line-height: 1.4;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.hairline-row:hover .hairline-title {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hairline-title {
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
  font-weight: 500;
  transition: color 160ms ease;
}

a.hairline-row {
  text-decoration: none;
}

a.hairline-row:visited .hairline-title {
  color: var(--text);
}

.hairline-line {
  flex: 1 1 auto;
  height: 0;
  border-bottom: 1px dotted var(--border);
  min-width: 0.75rem;
  margin-bottom: 0.3em;
}

.hairline-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-subtle);
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ensure dates in experience section never truncate */
.experience-item .hairline-meta,
.experience-item summary .hairline-meta,
.timeline-period-badge {
  max-width: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* Link rows site-wide — navbar-style hover block (bg + radius, no underline) */
a.hairline-row {
  padding: 0.38rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius-sm);
}

a.hairline-row:hover {
  background-color: var(--bg-subtle);
}

a.hairline-row:hover .hairline-title {
  color: var(--text);
  text-decoration: none;
}

@media (max-width: 768px) {
  .hairline-row {
    gap: var(--space-2);
    padding: 0.32rem 0;
  }

  a.hairline-row {
    padding: 0.32rem 0.35rem;
    margin: 0 -0.35rem;
  }

  .hairline-line {
    min-width: 0.5rem;
  }
}

/* ==========================================================================
   Experience List & Details Accordions
   ========================================================================== */

.experience-list,
.certifications-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.experience-item,
.cert-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 160ms ease;
}

.experience-item:hover,
.cert-item:hover {
  border-color: var(--border-strong);
}

.experience-item summary,
.cert-item summary {
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.experience-item summary::-webkit-details-marker,
.cert-item summary::-webkit-details-marker {
  display: none;
}

.experience-item summary .hairline-line,
.cert-item summary .hairline-line {
  margin-bottom: 0.35em;
}

.experience-item summary > div:first-child,
.cert-item summary > div:first-child,
.cert-summary-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

.summary-chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--text-subtle);
  transition: transform 240ms cubic-bezier(0.2, 0, 0, 1), color 160ms ease;
}

details[open].experience-item .summary-chevron,
details.is-opening.experience-item .summary-chevron,
details[open].cert-item .summary-chevron,
details.is-opening.cert-item .summary-chevron {
  transform: rotate(90deg);
  color: var(--link);
}

details.is-closing.experience-item .summary-chevron,
details.is-closing.cert-item .summary-chevron {
  transform: rotate(0deg);
  color: var(--text-subtle);
}

.experience-content-wrapper,
.cert-content-wrapper {
  overflow: hidden;
  transition: height 240ms cubic-bezier(0.2, 0, 0, 1);
}

.experience-body,
.cert-body {
  overflow: hidden;
  padding: var(--space-3) var(--space-4) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.experience-bullets a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 160ms ease;
}

.experience-bullets a:hover {
  color: var(--link);
}

.experience-role-location {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.experience-desc {
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.45;
  margin-bottom: var(--space-3);
}

.experience-bullets {
  margin: var(--space-2) 0 var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.experience-bullets li {
  margin-bottom: var(--space-1);
}

@media (max-width: 768px) {
  .experience-item summary,
  .cert-item summary {
    padding: 0.38rem 0.6rem;
  }

  .experience-body,
  .cert-body {
    padding: var(--space-2) var(--space-3) var(--space-3) var(--space-3);
  }

  .experience-bullets {
    margin: var(--space-2) 0 var(--space-3) var(--space-4);
  }
}

/* ==========================================================================
   Experience Dedicated Page (Timeline, Stats Dossier & Education)
   ========================================================================== */

.experience-page-header {
  margin-bottom: var(--space-8);
}

.experience-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.page-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--link);
  letter-spacing: 0.08em;
  margin-bottom: var(--space-1);
  text-transform: uppercase;
}

.page-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 1.15rem + 1.2vw, var(--text-2xl));
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.experience-intro {
  color: var(--text-muted);
  font-size: var(--text-base);
  line-height: 1.45;
  margin-top: var(--space-2);
  margin-bottom: var(--space-6);
  max-width: var(--prose-max-width);
}

/* Career Dossier Stats Bar */
.experience-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-8);
}

@media (max-width: 768px) {
  .experience-stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }
}

.experience-stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.experience-stat-num {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.experience-stat-label {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-subtle);
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Timeline Spine Layout */
.experience-timeline-section {
  margin-bottom: var(--space-10);
}

.timeline-spine-wrapper {
  position: relative;
  padding-left: var(--space-6);
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  margin-left: 0.5rem;
}

.timeline-entry {
  position: relative;
}

.timeline-marker {
  position: absolute;
  left: calc(-1 * var(--space-6) - 6px);
  top: 1.35rem;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  box-shadow: 0 0 0 3px var(--bg);
  z-index: 2;
}

.timeline-dot {
  display: none;
}

.timeline-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  transition: border-color 160ms ease;
}

.timeline-card:hover {
  border-color: var(--border-strong);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
}

.timeline-header-main {
  min-width: 0;
}

.timeline-role {
  font-family: var(--font-heading);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin: 0 0 0.25rem 0;
}

.timeline-company-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  flex-wrap: wrap;
}

.timeline-company {
  color: var(--link);
  font-weight: 600;
}

.timeline-bullet {
  color: var(--text-subtle);
}

.timeline-location {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-subtle);
}

.timeline-location svg {
  color: var(--text-subtle);
}

.timeline-period-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.timeline-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.timeline-desc {
  font-size: var(--text-base);
  color: var(--text);
  line-height: 1.45;
  margin: 0;
}

.timeline-subsection {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.timeline-subsection-title {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.timeline-bullets {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.timeline-bullets li {
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .timeline-spine-wrapper {
    padding-left: var(--space-4);
    margin-left: 0.25rem;
    gap: var(--space-4);
  }

  .timeline-marker {
    left: calc(-1 * var(--space-4) - 6px);
  }

  .timeline-card {
    padding: var(--space-4);
  }

  .timeline-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .timeline-period-badge {
    align-self: flex-start;
  }
}

/* Experience Education Section */
.experience-education-section {
  margin-top: var(--space-8);
}

.education-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.education-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  transition: border-color 160ms ease, background-color 160ms ease;
}

.education-card:hover {
  border-color: var(--border-strong);
}

.education-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.education-main {
  min-width: 0;
  flex: 1 1 300px;
}

.education-institution {
  font-family: var(--font-heading);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
}

.education-degree {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.education-meta-pill {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.education-meta-sep {
  color: var(--text-subtle);
  opacity: 0.6;
}

.education-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  margin-bottom: 0;
  line-height: 1.45;
}

/* ==========================================================================
   Project Cards & List
   ========================================================================== */

.projects-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.project-item {
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  min-width: 0;
  transition: border-color 160ms ease;
}

.project-item:hover {
  border-color: var(--border-strong);
}

/* ==========================================================================
   Selected Work — project cards (homepage)

   Header · title · description · tech tags · footer, in a two-up grid that
   stretches rows so cards in a row share a height. Everything is inline with
   the site token scale; no new colours.
   ========================================================================== */

.project-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: var(--space-4);
}

@media (max-width: 768px) {
  .project-card-grid {
    grid-template-columns: 1fr;
  }
}

.project-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
  transition: border-color 160ms ease, background-color 160ms ease;
}

.project-card:hover,
.project-card:focus-within {
  border-color: var(--border-strong);
  background-color: var(--bg-card-hover);
}

/* --- header: domain label left, restrained navigation arrow right --- */

.project-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.project-card-category {
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-subtle);
}

.project-card-arrow {
  flex: 0 0 auto;
  /* Keeps the arrow right-aligned even when a project has no category. */
  margin-left: auto;
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  transition: color 160ms ease, transform 160ms ease;
}

.project-card:hover .project-card-arrow,
.project-card:focus-within .project-card-arrow {
  color: var(--link);
  transform: translateX(3px);
}

/* --- title --- */

.project-card-title {
  margin: 0 0 var(--space-2);
  font-family: var(--font-heading);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.35;
}

.project-card-title a {
  color: var(--text);
  text-decoration: none;
}

.project-card-title a:hover,
.project-card-title a:focus-visible,
.project-card:focus-within .project-card-title a {
  color: var(--link);
}

/* --- description --- */

.project-card-desc {
  margin: 0 0 var(--space-4);
  font-size: var(--text-detail);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-muted);
}

/* --- technology tags --- */

.project-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.project-card-tag {
  max-width: 100%;
  padding: 0.15rem var(--space-2);
  border: 1px solid var(--tag-border);
  border-radius: var(--radius-sm);
  background-color: var(--tag-bg);
  color: var(--tag-text);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- footer: role + date range, pinned to the bottom of the card --- */

.project-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.project-card-role {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-period {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  color: var(--text-subtle);
}

.project-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.project-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-md);
  line-height: 1.35;
  color: var(--text);
  margin: 0;
}

.project-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 160ms ease;
}

.project-title a:visited {
  color: var(--text);
}

.project-title a:hover {
  color: var(--link);
  text-decoration: none;
}

.project-category {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.project-summary {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: var(--space-3);
}

.project-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.project-actions a {
  color: var(--link);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  font-weight: 500;
  transition: color 160ms ease;
}

.project-actions a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-actions a.primary-link {
  font-weight: 600;
}

/* ==========================================================================
   Badges, Tags & Skills Matrix
   ========================================================================== */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

@media (max-width: 640px) {
  .skills-grid {
    grid-template-columns: 1fr;
  }
}

.skill-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 160ms ease;
}

.skill-card:hover {
  border-color: var(--border-strong);
}

.skill-card-header {
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-2) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.skill-card-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.skill-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.skill-card-heading {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-count-badge {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-subtle);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  line-height: 1.2;
  flex-shrink: 0;
}

.skill-card-body {
  padding: var(--space-3) var(--space-4);
  flex: 1;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 0.15rem 0.45rem;
  background-color: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  word-break: break-word;
  max-width: 100%;
  line-height: 1.4;
  transition: var(--transition);
}

/* ==========================================================================
   Buttons System — Normalized, Geometric, No Gradients, No Shadows
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.45rem 0.9rem;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-border);
  background-color: var(--btn-bg);
  color: var(--btn-text);
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
  transition: var(--transition);
}

.btn:hover {
  background-color: var(--btn-bg-hover);
  border-color: var(--btn-border-hover);
  color: var(--btn-text);
  text-decoration: none !important;
}

.btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn:active {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: var(--primary) !important;
  color: #ffffff !important;
  border-color: var(--primary) !important;
  font-weight: 600;
}

.btn-primary:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  color: #ffffff !important;
}

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

[data-theme="dark"] .btn-primary {
  background-color: var(--primary) !important;
  color: #101a26 !important;
  border-color: var(--primary) !important;
}

[data-theme="dark"] .btn-primary:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  color: #101a26 !important;
}

.btn-secondary {
  background-color: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: var(--text-xs);
  gap: var(--space-1);
}

.btn-xs {
  padding: 0.2rem 0.45rem;
  font-size: var(--text-2xs);
  font-family: var(--font-mono);
}

/* ==========================================================================
   Article, Blog & Long-form Markdown Content
   ========================================================================== */

.markdown-page {
  position: relative;
  max-width: 100%;
}

.post-header {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  max-width: var(--prose-max-width);
}

.post-header h1 {
  font-size: clamp(1.4rem, 1.15rem + 1.2vw, var(--text-2xl));
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
}

.post-lede {
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: var(--space-2);
  margin-bottom: var(--space-3);
  max-width: var(--prose-max-width);
}

.post-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.prose {
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  max-width: var(--prose-max-width);
  width: 100%;
}

/* First/last child margin collapse fixes */
.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose h2 {
  font-size: clamp(1.25rem, 1.1rem + 0.4vw, var(--text-xl));
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-top: 1.25em;
  margin-bottom: 0.35em;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  scroll-margin-top: calc(var(--navbar-height) + 2.5rem);
}

.prose h3 {
  font-size: clamp(1.1rem, 1rem + 0.3vw, var(--text-lg));
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-top: 1.1em;
  margin-bottom: 0.3em;
  scroll-margin-top: calc(var(--navbar-height) + 2.5rem);
}

.prose h4 {
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1em;
  margin-bottom: 0.3em;
  scroll-margin-top: calc(var(--navbar-height) + 2.5rem);
}

.prose p {
  margin-bottom: 0.6em;
  line-height: 1.55;
}

.prose ul,
.prose ol {
  margin: 0 0 0.6em;
  padding-left: 1.3em;
  line-height: 1.5;
}

.prose li {
  margin-bottom: 0.2em;
}

.prose li:last-child {
  margin-bottom: 0;
}

.prose li > ul,
.prose li > ol {
  margin-top: 0.2em;
  margin-bottom: 0.2em;
}

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.prose a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 1.5px;
}

/* Inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
  word-break: break-word;
}

/* Code blocks */
.prose pre {
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.55;
  margin: var(--space-4) 0;
}

.prose pre code {
  font-size: inherit;
  line-height: inherit;
}

/* Tables — horizontal scroll wrapper via display:block */
.prose table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: var(--space-4) 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  font-size: var(--text-detail);
  line-height: 1.45;
}

.prose table th,
.prose table td {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-subtle);
  text-align: left;
  font-size: var(--text-detail);
  vertical-align: top;
}

.prose table th {
  background-color: var(--bg-subtle);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.prose table tr:nth-child(even) td {
  background-color: var(--bg-subtle);
}

.prose table td code {
  font-size: var(--text-xs);
  padding: 0.1rem 0.3rem;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .prose table {
    font-size: var(--text-xs);
    margin: var(--space-3) 0;
  }

  .prose table th,
  .prose table td {
    padding: 0.35rem 0.5rem;
    font-size: var(--text-xs);
  }

  .prose table td code {
    font-size: var(--text-2xs);
  }
}

/* Blockquote — clean accent rail, no italics */
.prose blockquote {
  margin: var(--space-4) 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--accent);
  background-color: transparent;
  border-radius: 0;
  color: var(--text-muted);
  font-style: normal;
  line-height: 1.6;
}

/* Media */
.prose img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
}

.prose figure {
  margin: var(--space-4) 0;
}

.prose figure img {
  margin-top: 0;
}

.prose figcaption {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  line-height: 1.4;
  margin-top: var(--space-2);
}

/* Horizontal rule */
.prose hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 1.5em 0;
}

/* Simple page head (About) */
.page-head {
  margin-bottom: var(--space-6);
}

.page-head h1 {
  margin-bottom: 0;
}

/* Listing page headers (Blog / Projects / Research) */
.listing-header {
  margin-bottom: var(--space-8);
  max-width: var(--prose-max-width);
}

.listing-header h1 {
  margin-bottom: var(--space-2);
}

.listing-intro {
  color: var(--text-muted);
  font-size: var(--text-base);
  line-height: 1.6;
  margin-top: var(--space-2);
  margin-bottom: 0;
}

.post-cover-image-container {
  margin-top: var(--space-4);
  margin-bottom: 0;
}

.post-cover-image {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Syntax Highlighting (Clean, Contemporary Terminal Colors)
   ========================================================================== */

pre[class*="language-"] {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
}

code[class*="language-"] {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--text-subtle);
  font-style: italic;
}

.token.punctuation {
  color: var(--text);
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
  color: #b91c1c;
}

[data-theme="dark"] .token.property,
[data-theme="dark"] .token.tag,
[data-theme="dark"] .token.boolean,
[data-theme="dark"] .token.number,
[data-theme="dark"] .token.constant,
[data-theme="dark"] .token.symbol {
  color: #f87171;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin {
  color: #15803d;
}

[data-theme="dark"] .token.selector,
[data-theme="dark"] .token.attr-name,
[data-theme="dark"] .token.string,
[data-theme="dark"] .token.char,
[data-theme="dark"] .token.builtin {
  color: #4ade80;
}

.token.operator,
.token.entity,
.token.url {
  color: var(--text);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #1d4ed8;
  font-weight: 600;
}

[data-theme="dark"] .token.atrule,
[data-theme="dark"] .token.attr-value,
[data-theme="dark"] .token.keyword {
  color: #60a5fa;
  font-weight: 600;
}

.token.function,
.token.class-name {
  color: #003366;
  font-weight: 600;
}

[data-theme="dark"] .token.function,
[data-theme="dark"] .token.class-name {
  color: #fbbf24;
  font-weight: 600;
}

.token.regex,
.token.important,
.token.variable {
  color: #7e22ce;
}

[data-theme="dark"] .token.regex,
[data-theme="dark"] .token.important,
[data-theme="dark"] .token.variable {
  color: #c084fc;
}

/* ==========================================================================
   Mermaid Diagrams — Minimalist Technical Cleanliness
   ========================================================================== */

.mermaid-container {
  position: relative;
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mermaid-container .mermaid {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.mermaid svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.mermaid .node rect,
.mermaid .cluster foreignobject rect {
  fill: var(--bg-card);
  stroke: var(--border);
  stroke-width: 1px;
  rx: 4;
}

.mermaid .node text,
.mermaid .cluster-title,
.mermaid .legend-text {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.mermaid .cluster group {
  stroke: var(--border-subtle);
  stroke-width: 1px;
  stroke-dasharray: 3, 3;
  fill: var(--bg);
  fill-opacity: 0.5;
}

.mermaid .edgePath path {
  stroke: var(--text-muted);
  stroke-width: 1.5px;
}

.mermaid .edgeLabel {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  fill: var(--text-subtle);
}

.mermaid .arrowhead,
.mermaid .arrowheadLink {
  fill: var(--text-muted);
}

@media (max-width: 768px) {
  .mermaid-container {
    padding: var(--space-3);
    margin: var(--space-4) 0;
  }

  .mermaid-container .mermaid,
  .mermaid .node text,
  .mermaid .cluster-title,
  .mermaid .legend-text {
    font-size: var(--text-xs);
  }

  .mermaid .edgeLabel {
    font-size: var(--text-2xs);
  }
}

/* ==========================================================================
   Table of Contents — Floating Utility
   ========================================================================== */

.markdown-page .toc-wrapper {
  position: sticky;
  top: calc(var(--navbar-height) + var(--space-3));
  right: 0;
  width: max-content;
  margin-left: auto;
  z-index: 50;
  margin-bottom: var(--space-2);
}

.toc-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
}

.toc-toggle-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text);
}

.toc-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: min(320px, calc(100vw - 2rem));
  max-height: min(420px, 70vh);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.toc-panel.is-open {
  display: flex;
}

.toc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}

.toc-panel-title {
  color: var(--text);
  font-weight: 600;
}

.toc-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
}

.toc-close-btn:hover {
  background-color: var(--bg-card);
  color: var(--text);
}

.toc-nav {
  padding: var(--space-2) var(--space-3);
  overflow-y: auto;
  flex: 1 0 auto;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-item {
  line-height: 1.4;
}

.toc-item a {
  display: block;
  padding: 0.25rem 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.toc-item a:hover {
  color: var(--text);
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.toc-level-h3 {
  padding-left: var(--space-3);
}

.toc-level-h4 {
  padding-left: var(--space-5);
}

.toc-backdrop {
  display: none !important;
}

/* ==========================================================================
   Back to Top Utility Button
   ========================================================================== */

.back-to-top {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}

.back-to-top:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text);
}

.back-to-top[hidden] {
  display: none;
}

/* ==========================================================================
   Loaders & Progressive Enhancement
   ========================================================================== */

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--link);
  transform: scaleX(0);
  transform-origin: left;
  z-index: 10000;
  pointer-events: none;
  transition: transform 180ms ease-out;
}

.page-loader.is-loading {
  transform: scaleX(1);
}

.page-loader.is-complete {
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 240ms ease-in;
}

.image-loader {
  position: relative;
  display: inline-block;
  overflow: hidden;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
}

.image-loader img {
  opacity: 0;
  transition: opacity 200ms ease;
}

.image-loader img.loaded,
.image-loader.loaded img {
  opacity: 1;
}

.mermaid-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.mermaid-loader .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--link);
  border-radius: var(--radius-full);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.mermaid-loader.loaded .spinner {
  display: none;
}

.mermaid-loader .mermaid {
  display: none;
}

.mermaid-loader.loaded .mermaid {
  display: block;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-8) 0;
  font-size: var(--text-xs);
  color: var(--text-subtle);
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  font-family: var(--font-sans);
  flex-shrink: 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding: 0 var(--space-8);
}

.footer-copyright {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.footer-divider {
  color: var(--border);
  user-select: none;
  font-size: var(--text-xs);
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-xs);
  transition: color 160ms ease;
}

.footer-links a:hover {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 960px) {
  .site-footer {
    padding: var(--space-6) 0;
  }

  .footer-inner {
    padding: 0 var(--space-5);
  }
}

@media (max-width: 640px) {
  .site-footer {
    padding: var(--space-5) 0 var(--space-8);
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    padding: 0 var(--space-4);
  }

  .footer-copyright {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    line-height: 1.4;
  }

  .footer-copyright span:last-child {
    margin-left: 0 !important;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
  }

  .footer-divider {
    display: none;
  }
}

/* ==========================================================================
   Contact Block (About page)
   ========================================================================== */

.contact-block {
  margin-top: var(--space-5);
  max-width: var(--prose-max-width);
}

.contact-block-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.contact-rows .hairline-row {
  padding: 0.4rem 0.6rem;
}

.contact-note {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: var(--space-3);
  margin-bottom: 0;
}

/* ==========================================================================
   404 Page — Lost in the cloud
   ========================================================================== */

.notfound-page {
  max-width: var(--prose-max-width);
  padding: var(--space-10) 0;
}

.notfound-code {
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 2rem + 8vw, 6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text-subtle);
  margin-bottom: var(--space-4);
}

.notfound-title {
  margin-bottom: var(--space-2);
}

.notfound-text {
  font-size: var(--text-md);
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-6);
}

.notfound-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .site-sidebar,
  .site-navbar,
  .site-footer,
  .theme-toggle-btn,
  .back-to-top,
  .toc-wrapper {
    display: none !important;
  }

  .layout-wrapper {
    display: block !important;
    padding: 0 !important;
  }

  .main-content {
    max-width: 100% !important;
  }

  a {
    text-decoration: underline !important;
    color: #000000 !important;
  }
}
