@media (max-width: 840px) {
  :root { --sidebar-w: 100%; }
  .app { grid-template-columns: 1fr; }
  .topbar-nav { gap: 0.2rem; font-size: 0.78rem; }
}

/* Very narrow phones: collapse the Shortcuts label to "?" so the brand
   still fits on one line. aria-label keeps the full wording for a11y. */
@media (max-width: 480px) {
  .topbar-help .help-full { display: none; }
  .topbar-help .help-short { display: inline; }
  .topbar-help {
    padding: 0.25rem 0.55rem;
    font-size: 0.95rem;
    min-width: 1.8rem;
  }
}

@media (max-width: 840px) {

  /* Sidebar becomes an inline band above the workshop on mobile — no
     overlay, nothing to "open", everything the user needs to adjust stays
     in the same scroll. Brush + Palette sit on top; everything else lives
     behind the More toggle so the canvas is reachable without a hunt. */
  .sidebar {
    position: static;
    border-right: none;
    padding: 0.6rem 0.75rem 0.5rem;
    gap: 0.55rem;
    max-height: none;
  }

  /* Full-width sidebar on mobile makes aspect-ratio:1 brush buttons
     blow up to ~25% of viewport width each. Cap the height instead. */
  .brush-btn { aspect-ratio: auto; height: 64px; }

  /* Collapsible extras — give it back a block box so the toggle and body
     stack normally inside the sidebar's flex column. */
  .sb-extras {
    display: flex; flex-direction: column; gap: 0.5rem;
  }
  .sb-extras-toggle {
    display: inline-flex; align-items: center; gap: 0.5rem;
    width: 100%; padding: 0.5rem 0.75rem;
    background: var(--paper); color: var(--ink);
    border: 1.5px solid var(--ink); border-radius: 12px;
    font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 0.82rem;
    cursor: pointer; box-shadow: 1.5px 1.5px 0 var(--ink);
    transition: background 0.12s ease;
  }
  .sb-extras-toggle:hover { background: var(--sun); }
  .sb-extras-label { font-weight: 700; }
  .sb-extras-hint {
    font-weight: 500; font-size: 0.7rem; color: var(--ink-soft);
    letter-spacing: 0.02em;
  }
  .sb-extras-caret {
    margin-left: auto; font-size: 0.75rem;
    transition: transform 0.18s ease;
  }
  .sb-extras-toggle[aria-expanded="true"] .sb-extras-caret { transform: rotate(180deg); }
  .sb-extras-body {
    display: none;
    flex-direction: column; gap: 0.75rem;
    padding: 0.15rem 0.1rem 0.25rem;
  }
  .sb-extras-toggle[aria-expanded="true"] + .sb-extras-body { display: flex; }

  .main { padding: 0.75rem; gap: 0.75rem; }
  .workshop-header { padding: 0.5rem 0.6rem; gap: 0.5rem; }
  /* Below this width, let each group shrink and scroll internally again —
     otherwise the forced intrinsic width would shove recipe off-screen. */
  .wh-stats, .wh-recipe { flex-shrink: 1; min-width: 0; }
  .workshop-header > .wh-recipe { margin-left: 0; }
  .wh-chip b { font-size: 0.8rem; }

  /* Square, fixed size on mobile — width capped so aspect-ratio keeps
     the height inside the viewport. */
  .stage-wrap {
    width: min(100%, 55vh);
    width: min(100%, 55dvh, 55vh);
  }
  .stage {
    padding: 0.4rem;
  }
}

@media (max-width: 380px) {
  .topbar-brand { font-size: 0.95rem; }
  .brand-dot { width: 20px; height: 20px; }
  .hero-strip h1 { font-size: 0.92rem; }
  .cat-btn { font-size: 1.1rem; }
  .swatch-box { width: 28px; height: 28px; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
}
