:root {
    /* Native system sans-serif stack: uses San Francisco on iOS, Roboto on Android */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
                 Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  }
  
  html {
    font-family: var(--font-sans);
    /* 16px base prevents iOS Safari from auto-zooming when tapping form inputs */
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
  }
  
  body {
    font-family: var(--font-sans);
    /* Fluid body text scales smoothly between 16px on mobile and 18px on desktop */
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    line-height: 1.6;
    color: #1a1a1a;
    background-color: #ffffff;
    margin: 0;
    /* Indent all page content from the edges; scales from 1.5rem on mobile to 4rem on desktop */
    padding: 1rem clamp(1.5rem, 5vw, 4rem);
    /* Improves font legibility on mobile screens */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  
  /* Fluid Headings */
  h1, h2, h3, h4 {
    line-height: 1.25;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 700;
  }
  
  h1 { font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem); }
  h2 { font-size: clamp(1.35rem, 1.15rem + 1vw, 1.85rem); }
  h3 { font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem); }
  
  /* Keep paragraphs to an optimal reading width and prevent awkward overflow */
  p {
    margin-top: 0;
    margin-bottom: 1.25em;
    max-width: 65ch;
    overflow-wrap: break-word;
  }
  
  /* Ensure form controls inherit the font and avoid mobile zoom */
  input, button, textarea, select {
    font-family: inherit;
    font-size: 1rem;
  }
  /* Force sans-serif everywhere, overriding browser defaults (e.g. monospace for code, form controls) */
  *, *::before, *::after {
    font-family: var(--font-sans) !important;
  }

  /* Grey hyperlinks (same color before and after visiting) */
  a, a:visited {
    color: #6b6b6b;
  }

  a:hover {
    color: #1a1a1a;
  }

  /* Tabs: show only the clicked section; "writing" by default */
  nav a {
    font-size: clamp(1.35rem, 1.15rem + 1vw, 1.85rem);
    font-weight: 700;
    text-decoration: none;
    margin-right: 1.5rem;
  }

  section { display: none; }
  section:target,
  body:not(:has(section:target)) #writing { display: block; }

  /* Highlight the active tab */
  body:has(#projects:target) nav a[href="#projects"],
  body:has(#writing:target) nav a[href="#writing"],
  body:has(#etc:target) nav a[href="#etc"],
  body:not(:has(section:target)) nav a[href="#writing"] {
    color: #1a1a1a;
  }

  /* Keep post images within the page width */
  img {
    max-width: 100%;
    height: auto;
  }

  figure { margin: 1.5em 0; }
  figcaption { font-size: 0.9em; color: #6b6b6b; }

  /* Small social icons: grey, darken on hover like links */
  .social img {
    width: 18px;
    height: 18px;
    margin-right: 0.6rem;
    opacity: 0.55;
  }
  .social a:hover img { opacity: 0.9; }

  .contact { font-size: 0.9em; color: #6b6b6b; font-style: italic; }
