/* The sidebar is `position: fixed`, so it is out of flow and the body has a
   single in-flow child, `.page-wrap`. `display: flex` here therefore bought
   nothing, but it did real damage: it made `.page-wrap` a flex item, so
   `flex: 1` sized it to the *whole* viewport width, and its
   `margin-left: var(--sidebar-width)` then pushed it past the right edge by
   exactly the sidebar width. Every page carried a 350px horizontal scrollbar
   (measured: document scrollWidth 1735 against a 1385 viewport). Plain block
   flow gives the wanted result for free — the auto width of a block box
   already shrinks by its own left margin. */
body { display: block; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;           
  max-height: 100vh;       
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0; left: 0;
  overflow-y: auto;        
  flex-shrink: 0;
  box-sizing: border-box;  
}

.sidebar-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}
.site-title {
  display: block;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--size-sm);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li { margin-bottom: 0.1rem; }
.sidebar-nav a {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--size-sm);
  color: var(--color-text);
  padding: 0.4rem 0.6rem;
  border-radius: 3px;
  transition: background 0.15s;
}
.sidebar-nav a:hover { background: var(--color-accent-soft); text-decoration: none; }
.sidebar-nav a.active { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 600; }

.page-wrap {
  margin-left: var(--sidebar-width);
  padding: 1rem var(--page-pad-x) 2rem var(--page-pad-x);
}

/* ── MOBILE FIXES ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* The sidebar returns to the flow here (position: relative below), and block
     flow already stacks it above `.page-wrap`, so no column direction is
     needed — the old `flex-direction: column` went inert with body's flex. */

  .sidebar { 
    position: relative; 
    width: 100%; 
    height: auto;       
    max-height: none;   
    border-right: none; 
    border-bottom: 1px solid var(--color-border); 
    padding: 1rem;      
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .sidebar-nav li { 
    margin-bottom: 0; 
  }
  .sidebar-nav a {
    font-size: 1.1rem;  
    padding: 0.5rem 0.9rem; 
    background: var(--color-accent-soft); 
  }

  .page-wrap { 
    margin-left: 0; 
    /* FIX: Reduced top padding on mobile from 1.5rem to 1rem */
    padding: 1rem; 
  }
}
