/* === Reader CSS Normalizer + Dark Mode + Scrollbar Enhancements === */

/* Global reset & setup */
*, *::before, *::after {
    box-sizing: border-box;
  }
  html, body {
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  
  /* Text smoothing and font setup */
  html {
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  
  body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #222;
    background-color: #fff;
    max-width: 70ch;
    margin: auto;
    padding: 2rem 1rem;
  }
  
  /* Headings */
  h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin: 2em 0 1em;
    line-height: 1.25;
  }
  
  /* Paragraphs & Lists */
  p {
    margin: 1em 0;
  }
  ul, ol {
    padding-left: 1.5rem;
    margin: 1em 0;
  }
  li {
    margin: 0.5em 0;
  }
  
  /* Links */
  a {
    color: inherit;
    text-decoration: underline;
  }
  a:visited {
    color: inherit;
  }
  
  /* Media */
  img, video {
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
  }
  
  /* Tables */
  table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
  }
  th, td {
    border: 1px solid #ddd;
    padding: 0.5em;
    text-align: left;
  }
  
  /* Blockquotes */
  blockquote {
    margin: 1em 0;
    padding-left: 1rem;
    border-left: 4px solid #ccc;
    color: #555;
    font-style: italic;
  }
  
  /* Code */
  pre, code {
    font-family: monospace;
    background: #f6f6f6;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.95em;
    overflow-x: auto;
  }
  pre {
    padding: 1em;
    white-space: pre-wrap;
  }
  
  /* HR */
  hr {
    border: none;
    border-top: 1px solid #ccc;
    margin: 2em 0;
  }
  
  /* Superscript & Subscript */
  sub, sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }
  sup { top: -0.4em; }
  sub { bottom: -0.25em; }
  
  /* Forms */
  input, textarea, select, button {
    font: inherit;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    outline: none;
    color: inherit;
  }
  
  /* Selection */
  ::selection {
    background: #dfe8ff;
  }
  
  /* Scroll padding for mobile keyboard */
  @media (max-width: 600px) {
    html, body {
      scroll-padding-bottom: 4rem;
    }
  }
  
  /* --- SCROLLBAR STYLES --- */
  
  /* WebKit scrollbar customization */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  
  /* Firefox scrollbar (basic support) */
  html {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
  }
  
  /* Hide scrollbars in overflow areas if needed */
  /*
  .scroll-hidden {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .scroll-hidden::-webkit-scrollbar {
    display: none;
  }
  */
  
  /* === DARK MODE === */
  @media (prefers-color-scheme: dark) {
    body {
      background-color: #121212;
      color: #e4e4e4;
    }
  
    a {
      color: #90caf9;
    }
  
    blockquote {
      border-left-color: #555;
      color: #aaa;
    }
  
    pre, code {
      background: #1e1e1e;
      color: #dcdcdc;
    }
  
    hr {
      border-top-color: #444;
    }
  
    th, td {
      border-color: #444;
    }
  
    ::selection {
      background: #334155;
    }
  
    /* Dark scrollbars */
    ::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.2);
    }
    html {
      scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    }
  }