/* ===== Mobile responsive — off-canvas sidebar drawer =====
   Loaded last so it overrides layout.css. Desktop is untouched. */

.menu-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  /* Hamburger button in the topbar */
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 0.6rem;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    color: var(--text);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .menu-toggle:active { background: rgba(124, 106, 252, 0.15); }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    height: 100vh;
    height: 100dvh;
    width: 82vw;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 18px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open { transform: translateX(0); }

  /* Dimmed backdrop behind the open drawer */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* Main column takes the full width */
  .main {
    width: 100%;
    min-width: 0;
  }

  /* Sticky topbar so the menu is always reachable */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.75rem 1rem;
  }
  .topbar-title { font-size: 0.95rem; }
  .topbar-status {
    font-size: 0.62rem;
    text-align: right;
    line-height: 1.2;
  }

  .content {
    padding: 1rem 0.85rem;
    padding-bottom: calc(1rem + 40px);
  }

  /* Keep wide content from blowing out the viewport */
  body { overflow-x: hidden; }
  .content img,
  .content canvas,
  .content pre,
  .content video { max-width: 100%; height: auto; }
  /* Wide tables scroll horizontally instead of stretching the page */
  .content table { display: block; width: 100%; overflow-x: auto; }
}
